-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
114 lines (83 loc) · 3.78 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
cmake_minimum_required(VERSION 3.10)
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(Red "${Esc}[32m")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_COMPILER $ENV{CC})
set(CMAKE_CXX_COMPILER $ENV{CXX})
option(NGEN "NGEN" OFF)
option(STANDALONE "STANDALONE" OFF)
option(STANDALONE "PFRAMEWORK" OFF)
if(NGEN)
message("ngen framework build")
add_definitions(-DNGEN)
endif(NGEN)
if(NOT STANDALONE AND NOT PFRAMEWORK AND NOT NGEN)
message("${Red}Options: STANDALONE, PFRAMEWORK, NGEN" ${ColourReset})
message(FATAL_ERROR "Invalid option is provided, CMake will exit." )
endif()
# set the project name
project(sftbmi VERSION 1.0.0 DESCRIPTION "OWP SFT BMI Module Shared Library")
set(CMAKE_BUILD_TYPE Debug)
IF(CMAKE_BUILD_TYPE MATCHES Debug)
message("Debug build.")
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
message("CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}")
message("CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}")
message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
if(STANDALONE)
message("${Red} Soil freeze-thaw model standalone build! ${ColourReset}")
set(exe_name "sft_standalone")
elseif(PFRAMEWORK)
message("${Red} Soil freeze-thaw model pseudo-framework build! ${ColourReset}")
set(exe_name "sft_pframework")
elseif(NGEN)
message("${Red} Soil freeze-thaw model ngen-framework build! ${ColourReset}")
endif()
# add the executable
## cfe + aorc + pet + ftm
if(PFRAMEWORK)
add_executable(${exe_name} ./src/main_pseudo_framework.cxx
./extern/cfe/src/cfe.c ./extern/cfe/src/bmi_cfe.c
./extern/cfe/src/giuh.c ./extern/cfe/src/conceptual_reservoir.c ./extern/cfe/src/nash_cascade.c
./extern/aorc_bmi/src/aorc.c ./extern/aorc_bmi/src/bmi_aorc.c
./extern/evapotranspiration/src/pet.c ./extern/evapotranspiration/src/bmi_pet.c)
add_library(sftlib ./src/bmi_soil_freeze_thaw.cxx ./src/soil_freeze_thaw.cxx
./include/bmi_soil_freeze_thaw.hxx ./include/soil_freeze_thaw.hxx
./extern/SoilMoistureProfiles/src/bmi_soil_moisture_profile.cxx
./extern/SoilMoistureProfiles/src/soil_moisture_profile.cxx
./extern/SoilMoistureProfiles/include/bmi_soil_moisture_profile.hxx
./extern/SoilMoistureProfiles/include/soil_moisture_profile.hxx)
target_link_libraries(${exe_name} LINK_PUBLIC sftlib)
target_link_libraries(${exe_name} PRIVATE m)
target_include_directories(${exe_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/extern/cfe/include)
target_include_directories(${exe_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/extern/)
elseif(STANDALONE)
add_executable(${exe_name} ./src/main_standalone.cxx ./src/bmi_soil_freeze_thaw.cxx ./src/soil_freeze_thaw.cxx)
endif()
##for NGEN BUILD
# ngen SFT (add shared library)
set(SFT_LIB_NAME_CMAKE sftbmi)
set(SFT_LIB_DESC_CMAKE "OWP SFT BMI Module Shared Library")
# Make sure these are compiled with this directive
add_compile_definitions(BMI_ACTIVE)
if(WIN32)
add_library(sftbmi src/bmi_soil_freeze_thaw.cxx src/soil_freeze_thaw.cxx)
else()
add_library(sftbmi SHARED src/bmi_soil_freeze_thaw.cxx src/soil_freeze_thaw.cxx)
endif()
target_include_directories(sftbmi PRIVATE include)
set_target_properties(sftbmi PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(sftbmi PROPERTIES PUBLIC_HEADER ./include/bmi_soil_freeze_thaw.hxx)
include(GNUInstallDirs)
install(TARGETS sftbmi
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
configure_file(sftbmi.pc.in sftbmi.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/sftbmi.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
unset(STANDALONE CACHE)
unset(PFRAMEWORK CACHE)
unset(NGEN CACHE)