Skip to content

Commit

Permalink
Merge pull request #8823 from NREL/8722_HVAC_Diagram
Browse files Browse the repository at this point in the history
Fix #8722 - HVAC-Diagram.exe broken in v9.5 (Modernize CMake Fortran Settings)
  • Loading branch information
Myoldmopar authored Jul 16, 2021
2 parents f44c136 + 92070af commit 72ede25
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 394 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ add_subdirectory(src/ConvertInputFormat)

if(BUILD_FORTRAN)
include(CMakeAddFortranSubdirectory)
# Define a top-level target `fortran_project_options`
include(cmake/Fortran.cmake)
cmake_add_fortran_subdirectory(
src/ExpandObjects
PROJECT ExpandObjects
Expand Down
10 changes: 5 additions & 5 deletions cmake/Fortran.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(FORTRAN_SKIP_RPATH FALSE)
if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(fortran_project_options INTERFACE -fpp)
target_compile_options(fortran_project_options INTERFACE -static-intel)
target_link_options(fortran_project_options INTERFACE -static-intel)
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(fortran_project_options INTERFACE -cpp)
Expand All @@ -15,26 +15,26 @@ elseif(UNIX)
set(FORTRAN_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(fortran_project_options INTERFACE -fpp)
target_compile_options(fortran_project_options INTERFACE -static-intel)
target_link_options(fortran_project_options INTERFACE -static-intel)
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(fortran_project_options INTERFACE -cpp)
endif()
target_compile_options(fortran_project_options INTERFACE -static)
set(FORTRAN_STATIC_EXE TRUE)
target_link_options(fortran_project_options INTERFACE -static)
endif()
else() # Windows
set(FORTRAN_STATIC_EXE TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
# Set release flags to be empty
set(CMAKE_Fortran_FLAGS_RELEASE "")
target_compile_options(fortran_project_options INTERFACE /libs:static)
target_compile_options(fortran_project_options INTERFACE /fpp)
target_link_options(fortran_project_options INTERFACE /libs:static)
else()
target_compile_options(fortran_project_options INTERFACE -static)
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(fortran_project_options INTERFACE -cpp)
endif()
target_link_options(fortran_project_options INTERFACE -static)
endif()
endif()
target_compile_options(fortran_project_options INTERFACE -ffree-line-length-275)
1 change: 1 addition & 0 deletions cmake/Install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ elseif(UNIX)
"/usr/local/${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}-${CPACK_PACKAGE_VERSION_MINOR}-${CPACK_PACKAGE_VERSION_PATCH}")

install(PROGRAMS "${PROJECT_SOURCE_DIR}/bin/EP-Compare/Run-Linux/EP-Compare" DESTINATION "PostProcess/EP-Compare/")
install(FILES "${PROJECT_SOURCE_DIR}/bin/EP-Compare/GraphHints.csv" DESTINATION "PostProcess/EP-Compare/")
install(FILES "${PROJECT_SOURCE_DIR}/bin/EP-Compare/Run-Linux/EP-Compare Libs/EHInterfaces5001.so"
DESTINATION "PostProcess/EP-Compare/EP-Compare Libs/")
install(FILES "${PROJECT_SOURCE_DIR}/bin/EP-Compare/Run-Linux/EP-Compare Libs/EHObjectArray5001.so"
Expand Down
52 changes: 10 additions & 42 deletions src/AppGPostProcess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,21 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")

set(SRC AppGPostProcess.f90)

set(STATIC_EXE FALSE)

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
set(STATIC_EXE TRUE)
endif()
else() # Windows
set(STATIC_EXE TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
# Set release flags to be empty
set(CMAKE_Fortran_FLAGS_RELEASE "")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /libs:static")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /fpp")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
endif()
endif()

set(CMAKE_SKIP_RPATH ${FORTRAN_SKIP_RPATH})
set(SKIP_BUILD_RPATH TRUE)

add_executable(AppGPostProcess ${SRC})
set_target_properties(AppGPostProcess PROPERTIES FOLDER Auxiliary)

if(NOT UNIX) # Need to reinclude it on Windows
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake")
endif()
get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS)
message(DEBUG "AppGPostProcess: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}")
target_link_libraries(AppGPostProcess PRIVATE fortran_project_options)

install(TARGETS AppGPostProcess DESTINATION PostProcess)
if(NOT ${STATIC_EXE})
if(NOT ${FORTRAN_STATIC_EXE})
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ProjectMacros.cmake")
install_target_prereqs(AppGPostProcess PostProcess)
endif()
67 changes: 38 additions & 29 deletions src/Basement/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,54 @@ set(SRC
InputProcessor.f90
BasementSimData.f90)

set(STATIC_EXE FALSE)
add_library(BasementOptions INTERFACE)
if(NOT CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(BasementOptions INTERFACE -ffloat-store)
endif()

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffloat-store")
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffloat-store")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
set(STATIC_EXE TRUE)
endif()
else() # Windows
set(STATIC_EXE TRUE)
if(NOT APPLE AND NOT UNIX) # Windows
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
# Set release flags to be empty
set(CMAKE_Fortran_FLAGS_RELEASE "")
set(CMAKE_Fortran_FLAGS
"/nologo /debug:minimal /O2 /Oy- /assume:buffered_io /noaltparam /fpscomp:nolibs /fpe:0 /fp:fast=2 /traceback /check:uninit /libs:static /threads /c /assume:protect-parens /Qprec-div /Qprec-sqrt /Qimf-precision:high /Qimf-arch-consistency:true /Qvec-"
)
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffloat-store")
target_compile_options(
BasementOptions
INTERFACE /nologo
/debug:minimal
/O2
/Oy-
/assume:buffered_io
/noaltparam
/fpscomp:nolibs
/fpe:0
/fp:fast=2
/traceback
/check:uninit
/libs:static
/threads
/c
/assume:protect-parens
/Qprec-div
/Qprec-sqrt
/Qimf-precision:high
/Qimf-arch-consistency:true
/Qvec-)
endif()
endif()

set(CMAKE_SKIP_RPATH ${FORTRAN_SKIP_RPATH})
set(SKIP_BUILD_RPATH TRUE)
add_executable(Basement ${SRC})

set_target_properties(Basement PROPERTIES COMPILE_FLAGS "-O1 -ffree-line-length-200 ${SHARED_FLAGS}")
add_executable(Basement ${SRC})
target_compile_options(Basement PRIVATE -O1)
set_target_properties(Basement PROPERTIES FOLDER Auxiliary)

if(NOT UNIX) # Need to reinclude it on Windows
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake")
endif()
get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS)
message(DEBUG "Basement: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}")
target_link_libraries(Basement PRIVATE BasementOptions fortran_project_options)

install(TARGETS Basement DESTINATION PreProcess/GrndTempCalc)
if(NOT ${STATIC_EXE})
if(NOT ${FORTRAN_STATIC_EXE})
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ProjectMacros.cmake")
install_target_prereqs(Basement PreProcess/GrndTempCalc)
endif()
Expand Down
52 changes: 10 additions & 42 deletions src/CalcSoilSurfTemp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,21 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")

set(SRC EPWRead.f90 SoilSurfTemp.f90)

set(STATIC_EXE FALSE)

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
set(STATIC_EXE TRUE)
endif()
else() # Windows
set(STATIC_EXE TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
# Set release flags to be empty
set(CMAKE_Fortran_FLAGS_RELEASE "")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /libs:static")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /fpp")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
endif()
endif()

set(CMAKE_SKIP_RPATH ${FORTRAN_SKIP_RPATH})
set(SKIP_BUILD_RPATH TRUE)

add_executable(CalcSoilSurfTemp ${SRC})
set_target_properties(CalcSoilSurfTemp PROPERTIES FOLDER Auxiliary)

if(NOT UNIX) # Need to reinclude it on Windows
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake")
endif()
get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS)
message(DEBUG "CalcSoilSurfTemp: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}")
target_link_libraries(CalcSoilSurfTemp PRIVATE fortran_project_options)

install(TARGETS CalcSoilSurfTemp DESTINATION PreProcess/CalcSoilSurfTemp)
if(NOT ${STATIC_EXE})
if(NOT ${FORTRAN_STATIC_EXE})
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ProjectMacros.cmake")
install_target_prereqs(CalcSoilSurfTemp PreProcess/CalcSoilSurfTemp)
endif()
32 changes: 8 additions & 24 deletions src/ConvertESOMTR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,21 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")

set(SRC mainModule.f90)

set(STATIC_EXE FALSE)

set(CMAKE_SKIP_RPATH ${FORTRAN_SKIP_RPATH})
set(SKIP_BUILD_RPATH TRUE)

add_executable(convertESOMTR ${SRC})
set_target_properties(convertESOMTR PROPERTIES FOLDER Auxiliary)

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
set(STATIC_EXE TRUE)
endif()
else()
set(STATIC_EXE TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
# Set release flags to be empty
set(CMAKE_Fortran_FLAGS_RELEASE "")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /libs:static")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
endif()
if(NOT UNIX) # Need to reinclude it on Windows
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake")
endif()
get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS)
message(DEBUG "ConvertESOMTR: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}")
target_link_libraries(convertESOMTR PRIVATE fortran_project_options)

install(TARGETS convertESOMTR DESTINATION "PostProcess/convertESOMTRpgm/")
if(NOT ${STATIC_EXE})
if(NOT ${FORTRAN_STATIC_EXE})
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ProjectMacros.cmake")
install_target_prereqs(convertESOMTR "PostProcess/convertESOMTRpgm/")
endif()
Expand Down
61 changes: 13 additions & 48 deletions src/ExpandObjects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,29 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")

set(SRC epfilter.f90)

if(WIN32)
# Include manifest
configure_file(ExpandObjects.rc.in "${CMAKE_CURRENT_BINARY_DIR}/ExpandObjects.rc")
list(APPEND SRC "${CMAKE_CURRENT_BINARY_DIR}/ExpandObjects.rc")
endif()

set(SRC epfilter.f90)

set(STATIC_EXE FALSE)
set(CMAKE_SKIP_RPATH ${FORTRAN_SKIP_RPATH})
set(SKIP_BUILD_RPATH TRUE)

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel")
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
set(STATIC_EXE TRUE)
endif()
else() # Windows
set(STATIC_EXE TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
# Set release flags to be empty
set(CMAKE_Fortran_FLAGS_RELEASE "")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /libs:static")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /fpp")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static")
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200")
endif()
endif()
add_executable(ExpandObjects ${SRC})
target_link_libraries(ExpandObjects PRIVATE fortran_project_options)

set(SKIP_BUILD_RPATH TRUE)
if(APPLE OR UNIX)
add_executable(ExpandObjects ${SRC})
else() # windows
add_executable(ExpandObjects ${SRC} "${CMAKE_CURRENT_BINARY_DIR}/ExpandObjects.rc")
if(NOT UNIX) # Need to reinclude it on Windows
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake")
endif()

get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS)
message(DEBUG "ExpandObjects: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}")
set_target_properties(ExpandObjects PROPERTIES FOLDER Auxiliary)

install(TARGETS ExpandObjects DESTINATION "./")
if(NOT ${STATIC_EXE})
if(NOT ${FORTRAN_STATIC_EXE})
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ProjectMacros.cmake")
install_target_prereqs(ExpandObjects "./")
endif()
Loading

1 comment on commit 72ede25

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2351 of 2351 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.