Skip to content

Commit

Permalink
Reorganize Fortran CMake settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lefticus committed Dec 15, 2020
1 parent 30b8df1 commit b059d34
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 363 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ add_subdirectory(src/ConvertInputFormat)

if(BUILD_FORTRAN)
include(CMakeAddFortranSubdirectory)
include(cmake/Fortran.cmake)

cmake_add_fortran_subdirectory(
src/ExpandObjects
PROJECT ExpandObjects
Expand Down
47 changes: 3 additions & 44 deletions src/AppGPostProcess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")

set(SRC AppGPostProcess.f90)

set(STATIC_EXE FALSE)

add_library(AppGPostProcessOptions INTERFACE)
if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(AppGPostProcessOptions INTERFACE -fpp)
target_compile_options(AppGPostProcessOptions INTERFACE -static-intel)
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(AppGPostProcessOptions INTERFACE -cpp)
endif()
target_compile_options(AppGPostProcessOptions INTERFACE -ffree-line-length-200)
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(AppGPostProcessOptions INTERFACE -fpp)
target_compile_options(AppGPostProcessOptions INTERFACE -static-intel)
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(AppGPostProcessOptions INTERFACE -cpp)
endif()
target_compile_options(AppGPostProcessOptions INTERFACE -static)
target_compile_options(AppGPostProcessOptions INTERFACE -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 "")
target_compile_options(AppGPostProcessOptions INTERFACE /libs:static)
target_compile_options(AppGPostProcessOptions INTERFACE /fpp)
else()
target_compile_options(AppGPostProcessOptions INTERFACE -static)
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(AppGPostProcessOptions INTERFACE -cpp)
endif()
target_compile_options(AppGPostProcessOptions INTERFACE -ffree-line-length-200)
endif()
endif()

set(SKIP_BUILD_RPATH TRUE)
set(CMAKE_SKIP_RPATH ${FORTRAN_SKIP_RPATH})
add_executable(AppGPostProcess ${SRC})
target_link_libraries(AppGPostProcess PRIVATE AppGPostProcessOptions)
target_link_libraries(AppGPostProcess PRIVATE fortran_project_options)
set_target_properties(AppGPostProcess PROPERTIES FOLDER Auxiliary)

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()
36 changes: 9 additions & 27 deletions src/Basement/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,13 @@ set(SRC
InputProcessor.f90
BasementSimData.f90)

set(STATIC_EXE FALSE)

add_library(BasementOptions INTERFACE)
if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(BasementOptions INTERFACE -static-intel)
else()
target_compile_options(BasementOptions INTERFACE -ffloat-store)
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(BasementOptions INTERFACE -static-intel)
else()
target_compile_options(BasementOptions INTERFACE -ffloat-store)
target_compile_options(BasementOptions INTERFACE -static)
set(STATIC_EXE TRUE)
endif()
else() # Windows
set(STATIC_EXE TRUE)
if(NOT CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(BasementOptions INTERFACE -ffloat-store)
endif()

if(NOT APPLE AND NOT UNIX) # Windows
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
# Set release flags to be empty
set(CMAKE_Fortran_FLAGS_RELEASE "")
target_compile_options(
BasementOptions
INTERFACE /nologo
Expand All @@ -64,23 +48,21 @@ else() # Windows
/Qimf-precision:high
/Qimf-arch-consistency:true
/Qvec-)
else()
target_compile_options(BasementOptions INTERFACE -static)
target_compile_options(BasementOptions INTERFACE -ffloat-store)
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")
"-O1")
set_target_properties(Basement PROPERTIES FOLDER Auxiliary)
target_link_libraries(Basement PRIVATE BasementOptions)
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
48 changes: 3 additions & 45 deletions src/CalcSoilSurfTemp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")

set(SRC EPWRead.f90 SoilSurfTemp.f90)

set(STATIC_EXE FALSE)

add_library(CalcSoilSurfTempOptions INTERFACE)

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(CalcSoilSurfTempOptions INTERFACE -fpp)
target_compile_options(CalcSoilSurfTempOptions INTERFACE -static-intel)
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(CalcSoilSurfTempOptions INTERFACE -cpp)
endif()
target_compile_options(CalcSoilSurfTempOptions INTERFACE -ffree-line-length-200)
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(CalcSoilSurfTempOptions INTERFACE -fpp)
target_compile_options(CalcSoilSurfTempOptions INTERFACE -static-intel)
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(CalcSoilSurfTempOptions INTERFACE -cpp)
endif()
target_compile_options(CalcSoilSurfTempOptions INTERFACE -static)
target_compile_options(CalcSoilSurfTempOptions INTERFACE -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 "")
target_compile_options(CalcSoilSurfTempOptions INTERFACE /libs:static)
target_compile_options(CalcSoilSurfTempOptions INTERFACE /fpp)
else()
target_compile_options(CalcSoilSurfTempOptions INTERFACE -static)
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(CalcSoilSurfTempOptions INTERFACE -cpp)
endif()
target_compile_options(CalcSoilSurfTempOptions INTERFACE -ffree-line-length-200)
endif()
endif()

set(CMAKE_SKIP_RPATH ${FORTRAN_SKIP_RPATH})
set(SKIP_BUILD_RPATH TRUE)
add_executable(CalcSoilSurfTemp ${SRC})
target_link_libraries(CalcSoilSurfTemp PRIVATE CalcSoilSurfTempOptions)
target_link_libraries(CalcSoilSurfTemp PRIVATE fortran_project_options)
set_target_properties(CalcSoilSurfTemp PROPERTIES FOLDER Auxiliary)

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: 4 additions & 28 deletions src/ConvertESOMTR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,16 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")

set(SRC mainModule.f90)

set(STATIC_EXE FALSE)

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

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

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(convertESOMTROptions INTERFACE -static-intel)
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(convertESOMTROptions INTERFACE -static-intel)
else()
target_compile_options(convertESOMTROptions INTERFACE -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 "")
target_compile_options(convertESOMTROptions INTERFACE /libs:static)
else()
target_compile_options(convertESOMTROptions INTERFACE -static)
endif()
endif()
target_link_libraries(convertESOMTR PRIVATE convertESOMTROptions)
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
49 changes: 4 additions & 45 deletions src/ExpandObjects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,20 @@ endif()

set(SRC epfilter.f90)

set(STATIC_EXE FALSE)

add_library(ExpandObjectsOptions INTERFACE)

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(ExpandObjectsOptions INTERFACE -fpp)
target_compile_options(ExpandObjectsOptions INTERFACE -static-intel)
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(ExpandObjectsOptions INTERFACE -cpp)
endif()
target_compile_options(ExpandObjectsOptions INTERFACE -ffree-line-length-200)
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(ExpandObjectsOptions INTERFACE -fpp)
target_compile_options(ExpandObjectsOptions INTERFACE -static-intel)
else()
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(ExpandObjectsOptions INTERFACE -cpp)
endif()
target_compile_options(ExpandObjectsOptions INTERFACE -static)
target_compile_options(ExpandObjectsOptions INTERFACE -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 "")
target_compile_options(ExpandObjectsOptions INTERFACE /libs:static)
target_compile_options(ExpandObjectsOptions INTERFACE /fpp)
else()
target_compile_options(ExpandObjectsOptions INTERFACE -static)
if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR})
target_compile_options(ExpandObjectsOptions INTERFACE -cpp)
endif()
target_compile_options(ExpandObjectsOptions INTERFACE -ffree-line-length-200)
endif()
endif()

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

if(APPLE OR UNIX)
add_executable(ExpandObjects ${SRC})
else() # windows
add_executable(ExpandObjects ${SRC} "${CMAKE_CURRENT_BINARY_DIR}/ExpandObjects.rc")
endif()

target_link_libraries(ExpandObjects ExpandObjectsOptions)
target_link_libraries(ExpandObjects PRIVATE fortran_project_options)
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()
42 changes: 7 additions & 35 deletions src/HVAC-Diagram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,19 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../../Products")

set(SRC HVAC-Diagram-Main.f90)

set(STATIC_EXE TRUE)

add_library(HVAC-Diagram-Options INTERFACE)

if(APPLE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(HVAC-Diagram-Options INTERFACE -static-intel)
else()
target_compile_options(HVAC-Diagram-Options INTERFACE -std=legacy)
target_compile_options(HVAC-Diagram-Options INTERFACE -ffree-line-length-200)
endif()
elseif(UNIX)
set(CMAKE_SKIP_RPATH TRUE)
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(HVAC-Diagram-Options INTERFACE -static-intel)
else()
target_compile_options(HVAC-Diagram-Options INTERFACE -static)
target_compile_options(HVAC-Diagram-Options INTERFACE -std=legacy)
target_compile_options(HVAC-Diagram-Options INTERFACE -ffree-line-length-200)
set(STATIC_EXE TRUE)
endif()
else()
if(CMAKE_Fortran_COMPILER MATCHES "ifort")
# Set release flags to be empty
set(CMAKE_Fortran_FLAGS_RELEASE "")
target_compile_options(HVAC-Diagram-Options INTERFACE /libs:static)
else()
target_compile_options(HVAC-Diagram-Options INTERFACE -static)
target_compile_options(HVAC-Diagram-Options INTERFACE -std=legacy)
target_compile_options(HVAC-Diagram-Options INTERFACE -ffree-line-length-200)
set(STATIC_EXE TRUE)
endif()
endif()

set(SKIP_BUILD_RPATH true)
set(CMAKE_SKIP_RPATH ${FORTRAN_SKIP_RPATH})
add_executable(HVAC-Diagram ${SRC})
target_link_libraries(HVAC-Diagram PRIVATE HVAC-Diagram-Options)
target_link_libraries(HVAC-Diagram PRIVATE fortran_project_options)
set_target_properties(HVAC-Diagram PROPERTIES FOLDER Auxiliary)
if(NOT CMAKE_Fortran_COMPILER MATCHES "ifort")
target_compile_options(HVAC-Diagram PRIVATE -std=legacy)
endif()


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

5 comments on commit b059d34

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

cmake_modernize (lefticus) - Win64-Windows-10-VisualStudio-16: Build Failed

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

cmake_modernize (lefticus) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: Build Failed

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

cmake_modernize (lefticus) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: Build Failed

Build Badge Test Badge Coverage Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

cmake_modernize (lefticus) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: Build Failed

Build Badge Test Badge Coverage Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

cmake_modernize (lefticus) - x86_64-MacOS-10.15-clang-11.0.0: Build Failed

Build Badge Test Badge

Please sign in to comment.