Skip to content

Commit

Permalink
Begin organization of Fortran CMake project modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
lefticus committed Dec 14, 2020
1 parent d7ffe27 commit 67f039d
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 62 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 17 additions & 14 deletions src/CalcSoilSurfTemp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,50 @@ 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
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")
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)
Expand Down
31 changes: 17 additions & 14 deletions src/ExpandObjects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,44 @@ 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
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")
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()

Expand All @@ -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 "./")
Expand Down
25 changes: 14 additions & 11 deletions src/HVAC-Diagram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions src/Slab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
38 changes: 21 additions & 17 deletions src/Transition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

5 comments on commit 67f039d

@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

@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

Please sign in to comment.