From 67f039decc4fe810a9f088b7aac121a84c607502 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 14 Dec 2020 13:46:13 -0700 Subject: [PATCH] Begin organization of Fortran CMake project modernization --- CMakeLists.txt | 2 +- src/CalcSoilSurfTemp/CMakeLists.txt | 31 ++++++++++++----------- src/ExpandObjects/CMakeLists.txt | 31 ++++++++++++----------- src/HVAC-Diagram/CMakeLists.txt | 25 ++++++++++--------- src/Slab/CMakeLists.txt | 13 ++++++---- src/Transition/CMakeLists.txt | 38 ++++++++++++++++------------- 6 files changed, 78 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dba72ac2b6..15ef5bc0290 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ endif() project(EnergyPlus) -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.10) if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER "3.0") cmake_policy(SET CMP0054 NEW) # CMake 3.1 added this policy diff --git a/src/CalcSoilSurfTemp/CMakeLists.txt b/src/CalcSoilSurfTemp/CMakeLists.txt index 0a96b843285..3894fde90f2 100644 --- a/src/CalcSoilSurfTemp/CMakeLists.txt +++ b/src/CalcSoilSurfTemp/CMakeLists.txt @@ -12,27 +12,29 @@ set(SRC EPWRead.f90 SoilSurfTemp.f90) set(STATIC_EXE FALSE) +add_library(CalcSoilSurfTempOptions INTERFACE) + 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") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -fpp) + target_compile_options(CalcSoilSurfTempOptions INTERFACE -static-intel) else() if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -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") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -fpp) + target_compile_options(CalcSoilSurfTempOptions INTERFACE -static-intel) else() if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -static) + target_compile_options(CalcSoilSurfTempOptions INTERFACE -ffree-line-length-200) set(STATIC_EXE TRUE) endif() else() # Windows @@ -40,19 +42,20 @@ else() # Windows 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") + target_compile_options(CalcSoilSurfTempOptions INTERFACE /libs:static) + target_compile_options(CalcSoilSurfTempOptions INTERFACE /fpp) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -static) if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + target_compile_options(CalcSoilSurfTempOptions INTERFACE -ffree-line-length-200) endif() endif() set(SKIP_BUILD_RPATH TRUE) add_executable(CalcSoilSurfTemp ${SRC}) +target_link_libraries(CalcSoilSurfTemp PRIVATE CalcSoilSurfTempOptions) set_target_properties(CalcSoilSurfTemp PROPERTIES FOLDER Auxiliary) install(TARGETS CalcSoilSurfTemp DESTINATION PreProcess/CalcSoilSurfTemp) diff --git a/src/ExpandObjects/CMakeLists.txt b/src/ExpandObjects/CMakeLists.txt index d9f9b920978..1750eb33a31 100644 --- a/src/ExpandObjects/CMakeLists.txt +++ b/src/ExpandObjects/CMakeLists.txt @@ -16,27 +16,29 @@ set(SRC epfilter.f90) set(STATIC_EXE FALSE) +add_library(ExpandObjectsOptions INTERFACE) + 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") + target_compile_options(ExpandObjectsOptions INTERFACE -fpp) + target_compile_options(ExpandObjectsOptions INTERFACE -static-intel) else() if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(ExpandObjectsOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + target_compile_options(ExpandObjectsOptions INTERFACE -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") + target_compile_options(ExpandObjectsOptions INTERFACE -fpp) + target_compile_options(ExpandObjectsOptions INTERFACE -static-intel) else() if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(ExpandObjectsOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + target_compile_options(ExpandObjectsOptions INTERFACE -static) + target_compile_options(ExpandObjectsOptions INTERFACE -ffree-line-length-200) set(STATIC_EXE TRUE) endif() else() # Windows @@ -44,14 +46,14 @@ else() # Windows 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") + target_compile_options(ExpandObjectsOptions INTERFACE /libs:static) + target_compile_options(ExpandObjectsOptions INTERFACE /fpp) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") + target_compile_options(ExpandObjectsOptions INTERFACE -static) if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(ExpandObjectsOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + target_compile_options(ExpandObjectsOptions INTERFACE -ffree-line-length-200) endif() endif() @@ -62,6 +64,7 @@ else() # windows add_executable(ExpandObjects ${SRC} "${CMAKE_CURRENT_BINARY_DIR}/ExpandObjects.rc") endif() +target_link_libraries(ExpandObjects ExpandObjectsOptions) set_target_properties(ExpandObjects PROPERTIES FOLDER Auxiliary) install(TARGETS ExpandObjects DESTINATION "./") diff --git a/src/HVAC-Diagram/CMakeLists.txt b/src/HVAC-Diagram/CMakeLists.txt index 09949b76608..3f8ce8aa84d 100644 --- a/src/HVAC-Diagram/CMakeLists.txt +++ b/src/HVAC-Diagram/CMakeLists.txt @@ -12,38 +12,41 @@ set(SRC HVAC-Diagram-Main.f90) set(STATIC_EXE TRUE) +add_library(HVAC-Diagram-Options INTERFACE) + if(APPLE) if(CMAKE_Fortran_COMPILER MATCHES "ifort") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel") + target_compile_options(HVAC-Diagram-Options INTERFACE -static-intel) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + 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") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel") + target_compile_options(HVAC-Diagram-Options INTERFACE -static-intel) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + 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 "") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /libs:static") + target_compile_options(HVAC-Diagram-Options INTERFACE /libs:static) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-200") + 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) add_executable(HVAC-Diagram ${SRC}) +target_link_libraries(HVAC-Diagram PRIVATE HVAC-Diagram-Options) set_target_properties(HVAC-Diagram PROPERTIES FOLDER Auxiliary) install(TARGETS HVAC-Diagram DESTINATION PostProcess) diff --git a/src/Slab/CMakeLists.txt b/src/Slab/CMakeLists.txt index 0199fe4984d..0aec91e3b1d 100644 --- a/src/Slab/CMakeLists.txt +++ b/src/Slab/CMakeLists.txt @@ -24,31 +24,34 @@ set(SRC set(STATIC_EXE FALSE) +add_library(SlabOptions INTERFACE) + if(APPLE) if(CMAKE_Fortran_COMPILER MATCHES "ifort") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel") + target_compile_options(SlabOptions INTERFACE -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") + target_compile_options(SlabOptions INTERFACE -static-intel) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") + target_compile_options(SlabOptions INTERFACE -static) set(STATIC_EXE TRUE) endif() else() 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") + target_compile_options(SlabOptions INTERFACE /libs:static) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") + target_compile_options(SlabOptions INTERFACE -static) set(STATIC_EXE TRUE) endif() endif() set(SKIP_BUILD_RPATH TRUE) add_executable(Slab ${SRC}) +target_link_libraries(Slab PRIVATE SlabOptions) set_target_properties(Slab PROPERTIES FOLDER Auxiliary) set_target_properties(Slab PROPERTIES COMPILE_FLAGS "-ffree-line-length-200 ${SHARED_FLAGS}") diff --git a/src/Transition/CMakeLists.txt b/src/Transition/CMakeLists.txt index 26b75632cf3..7c551801fbd 100644 --- a/src/Transition/CMakeLists.txt +++ b/src/Transition/CMakeLists.txt @@ -66,48 +66,52 @@ list(APPEND VERSIONS 9_2_0) list(APPEND VERSIONS 9_3_0) list(APPEND VERSIONS 9_4_0) +add_library(TransitionOptions INTERFACE) + if(APPLE) if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(TransitionOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fbounds-check") + target_compile_options(TransitionOptions INTERFACE -ffree-line-length-none) + target_compile_options(TransitionOptions INTERFACE -fbounds-check) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel") + target_compile_options(TransitionOptions INTERFACE -fpp) + target_compile_options(TransitionOptions INTERFACE -static-intel) endif() elseif(UNIX) set(CMAKE_SKIP_RPATH TRUE) if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") + target_compile_options(TransitionOptions INTERFACE -static) if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(TransitionOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fbounds-check") + target_compile_options(TransitionOptions INTERFACE -ffree-line-length-none) + target_compile_options(TransitionOptions INTERFACE -fbounds-check) set(STATIC_EXE TRUE) else() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-intel") + target_compile_options(TransitionOptions INTERFACE -fpp) + target_compile_options(TransitionOptions INTERFACE -static-intel) endif() else() # Windows set(STATIC_EXE TRUE) if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static") + target_compile_options(TransitionOptions INTERFACE -static) if(NOT "Ninja" STREQUAL ${CMAKE_GENERATOR}) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") + target_compile_options(TransitionOptions INTERFACE -cpp) endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fbounds-check") + target_compile_options(TransitionOptions INTERFACE -ffree-line-length-none) + target_compile_options(TransitionOptions INTERFACE -fbounds-check) else() # 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") + target_compile_options(TransitionOptions INTERFACE /libs:static) + target_compile_options(TransitionOptions INTERFACE /fpp) endif() endif() +target_compile_options(TransitionLib PUBLIC TransitionOptions) + list(LENGTH VERSIONS VERSIONS_SIZE) math(EXPR end "${VERSIONS_SIZE} - 1")