-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
140 lines (110 loc) · 4.33 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Require a certain version of cmake
cmake_minimum_required(VERSION 3.9)
# Set the name of the project
project(GEMS3K VERSION 4.4.0 LANGUAGES CXX C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MACOSX_RPATH ON)
# Include the cmake variables with values for installation directories
include(GNUInstallDirs)
# Set the cmake module path of the project
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# Use ccache to speed up repeated compilations
include(CCache)
# Ensure proper configuration if in a conda environment
include(CondaAware)
# Set the output directories of the built libraries and binaries
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Set libraries to be compiled with position independent code mode (i.e., fPIC option in GNU compilers)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Set the default build type to Release
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# Define which types of libraries to build
option(BUILD_SHARED_LIBS "Build shared libraries." ON)
option(BUILD_STATIC_LIBS "Build static libraries." ON)
option(USE_THERMOFUN "Use ThermoFun" ON)
option(BUILD_GEM2MT "Install GEM2MT lib." ON)
option(BUILD_NLOHMANNJSON "Use nlohmann json." OFF)
option(BUILD_TOOLS "Build tools" ON)
option(BUILD_SOLMOD "Build isolate TSolMod " ON)
# Used into conda only
if(DEFINED ENV{CONDA_PREFIX})
option(USE_SPDLOG_PRECOMPILED "Use spdlog in compiled version" ON)
else()
option(USE_SPDLOG_PRECOMPILED "Use spdlog in compiled version" OFF)
endif()
# Set the list of compiler flags for GNU compiler
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
add_compile_options( -pthread -Wall -Wno-misleading-indentation -Wno-ignored-attributes -Wno-variadic-macros -Wno-deprecated)
endif()
# Set the list of compiler flags for Clang compiler
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-mavx2 -Wall -Wno-ignored-attributes -Wno-pedantic -Wno-variadic-macros -Wno-deprecated)
endif()
# Set the list of compiler flags for Intel compiler
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Intel")
add_compile_options(-Wall -Wno-variadic-macros -Wno-deprecated)
endif()
# Set the list of compiler flags for MSVC compiler
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
add_compile_options(
/D_SCL_SECURE_NO_WARNINGS
/D_CRT_SECURE_NO_WARNINGS=1
/MP4
/EHsc
/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
/DNOMINMAX
)
endif()
# test thread safe
#set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread")
#set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=thread")
# Set the source directory path
set(GEMS3K_SOURCE_DIR ${CMAKE_SOURCE_DIR}/GEMS3K)
set(GEMS3K_HEADER_DIR ${CMAKE_SOURCE_DIR}/GEMS3K)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
include_directories("/usr/local/include")
link_directories("/usr/local/lib")
endif()
# Set the include directories
include_directories(${GEMS3K_HEADER_DIR})
include_directories(${CMAKE_SOURCE_DIR})
# Find all GEMS3K dependencies
include(GEMS3KFindDeps)
# Set some necessary definitions
add_definitions(-DNODEARRAYLEVEL)
if(USE_THERMOFUN MATCHES ON)
add_definitions(-DUSE_THERMOFUN)
#add_definitions(-DUSE_THERMO_LOG)
endif()
if(BUILD_NLOHMANNJSON MATCHES ON)
add_definitions(-DUSE_NLOHMANNJSON)
endif()
if(BUILD_GEM2MT MATCHES ON)
set(GEM2MT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/nodearray-gem)
set(GEM2MT_HEADER_DIR ${CMAKE_SOURCE_DIR}/nodearray-gem)
include_directories(${GEM2MT_HEADER_DIR})
endif()
# Compile GEMS3K
add_subdirectory(GEMS3K)
link_directories(${CMAKE_BINARY_DIR}/GEMS3K)
link_directories(${CMAKE_BINARY_DIR}/lib)
if(BUILD_GEM2MT MATCHES ON)
add_subdirectory(nodearray-gem)
link_directories(${CMAKE_BINARY_DIR}/nodearray-gem)
endif()
if(BUILD_TOOLS)
add_subdirectory(tools)
endif()
if(BUILD_SOLMOD)
add_subdirectory(tsolmod4rkt)
endif()
# Install the cmake config files that permit users to use find_package(gems3k)
include(GEMS3KInstallCMakeConfigFiles)