-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
203 lines (168 loc) · 6.14 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#####################
### OGS-6 Project ###
#####################
# Specify minimum CMake version
cmake_minimum_required(VERSION 3.1)
# Set CMake policies
cmake_policy(SET CMP0011 OLD)
cmake_policy(SET CMP0054 NEW)
# Project name
project( OGS-6 )
list(APPEND CMAKE_PREFIX_PATH
$ENV{HOMEBREW_ROOT} # Homebrew package manager on Mac OS
$ENV{CMAKE_LIBRARY_SEARCH_PATH} # Environment variable, Windows
${CMAKE_LIBRARY_SEARCH_PATH}) # CMake option, Windows
###########################
### Preliminary Options ###
###########################
set(CMAKE_LIBRARY_SEARCH_PATH "" CACHE PATH
"Additional library installation path, e.g. /opt/local or C:/libs")
set(OGS_CPU_ARCHITECTURE "native" CACHE STRING "Processor architecture, defaults to native.")
### CMake includes ###
include(scripts/cmake/CheckTypeSizes.cmake)
include(scripts/cmake/Functions.cmake)
include(scripts/cmake/CMakeSetup.cmake)
include(scripts/cmake/CompilerSetup.cmake)
include(scripts/cmake/Find.cmake)
include(scripts/cmake/SubmoduleSetup.cmake)
include(scripts/cmake/ProjectSetup.cmake)
include(scripts/cmake/DocumentationSetup.cmake)
include(scripts/cmake/test/Test.cmake)
if(OGS_COVERAGE AND NOT IS_SUBPROJECT)
include(scripts/cmake/Coverage.cmake)
endif()
####################
### More Options ###
####################
# Profiling
if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) AND GPROF_PATH)
option(OGS_PROFILE "Enables compiling with flags set for profiling with gprof." OFF)
endif() # GCC AND GPROF_PATH
# Enable / Disable parts
option(OGS_DONT_USE_QT "Disables all Qt specific code." OFF)
option(OGS_BUILD_CLI "Should the OGS simulator be built?" ON)
option(OGS_BUILD_TESTS "Should the test executables be built?" ON)
option(OGS_BUILD_GUI "Should the Data Explorer be built?" OFF)
if(OGS_BUILD_GUI)
add_definitions(-DOGS_BUILD_GUI)
endif()
option(OGS_BUILD_UTILS "Should the utilities programms be built?" OFF)
option(OGS_NO_EXTERNAL_LIBS "Builds OGS without any external dependencies." OFF)
# Linear solvers
option(OGS_USE_LIS "Use Lis" OFF)
option(OGS_USE_EIGENLIS "Use Lis solver together with Eigen sparse matrices" OFF)
# Parallel computing: vector and matrix algebraic caculation, solvers
option(OGS_USE_PETSC "Use PETSc routines" OFF)
# Paralleization
option(OGS_USE_MPI "Use MPI" OFF)
# Eigen
option(OGS_USE_EIGEN "Use EIGEN for local matrix and vector" ON)
option(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES "Use dynamically allocated shape matrices" ON)
option(EIGEN_NO_DEBUG "Disables Eigen's assertions" OFF)
# Logging
option(OGS_DISABLE_LOGGING "Disables all logog messages." OFF)
# Compiler flags
set(OGS_CXX_FLAGS "" CACHE STRING "Additional C++ compiler flags.")
option(STL_NO_DEBUG "Disable STL debug in debug build" OFF)
# Print CMake variable values
if (OGS_CMAKE_DEBUG)
include(ListAllCMakeVariableValues)
list_all_cmake_variable_values()
endif ()
# Code coverage
option(OGS_COVERAGE "Enables code coverage measurements with gcov/lcov." OFF)
# Packaging
option(OGS_DOWNLOAD_ADDITIONAL_CONTENT "Should addional content such as manuals be downloaded and packaged?" OFF)
include(scripts/cmake/packaging/Pack.cmake)
# Third-party libraries
# Default checks for system first, then builds locally
set(OGS_LIB_VTK "Default" CACHE STRING "Which VTK library should be used?")
set(OGS_LIB_BOOST "Default" CACHE STRING "Which Boost library should be used?")
set(OGS_LIB_EIGEN "Default" CACHE STRING "Which Eigen library should be used?")
set_property(CACHE
OGS_LIB_VTK
OGS_LIB_BOOST
OGS_LIB_EIGEN
PROPERTY STRINGS "Default" "System" "Local")
###################
### Definitions ###
###################
if(OGS_USE_LIS)
add_definitions(-DUSE_LIS)
include_directories(SYSTEM ${LIS_INCLUDE_DIR})
endif()
if(OGS_USE_PETSC)
add_definitions(-DUSE_PETSC)
set(OGS_USE_MPI ON CACHE BOOL "Use MPI" FORCE)
endif()
# Use MPI
if(OGS_USE_MPI)
add_definitions(-DUSE_MPI)
endif()
if(OGS_USE_EIGEN)
add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_ZERO)
add_definitions(-DOGS_USE_EIGEN)
if (EIGEN_NO_DEBUG)
add_definitions(-DEIGEN_NO_DEBUG)
endif()
if(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES)
add_definitions(-DOGS_EIGEN_DYNAMIC_SHAPE_MATRICES)
endif()
endif()
if(OGS_BUILD_TESTS)
set(Data_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Tests/Data CACHE INTERNAL "")
set(Data_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Tests/Data CACHE INTERNAL "")
endif()
######################
### Subdirectories ###
######################
# External projects
include(scripts/cmake/ExternalProjectBoost.cmake)
include(VtkModules)
if(OGS_INSITU)
include(ExternalProjectCatalyst)
else()
include(ExternalProjectVtk)
endif()
include_directories( SYSTEM ${Boost_INCLUDE_DIRS} )
if(OGS_USE_EIGEN)
include(scripts/cmake/ExternalProjectEigen.cmake)
include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})
endif()
# Add subdirectories with the projects
add_subdirectory( ThirdParty )
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty )
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/gtest/include )
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/autocheck/include )
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/tclap/include )
add_subdirectory( Applications )
add_subdirectory( AssemblerLib )
add_subdirectory( BaseLib )
# TODO This is a hack but we have to make sure that Boost is built first
if(TARGET Boost)
add_dependencies(BaseLib Boost)
endif()
add_subdirectory( FileIO )
add_subdirectory( GeoLib )
add_subdirectory( InSituLib )
add_subdirectory( MathLib )
add_subdirectory( MeshLib )
add_subdirectory( MeshGeoToolsLib )
add_subdirectory( NumLib )
add_subdirectory( ProcessLib )
if( OGS_BUILD_TESTS AND NOT IS_SUBPROJECT )
add_subdirectory( Tests )
if(OGS_USE_MPI)
add_subdirectory( SimpleTests/MeshTests/MPI )
else()
add_subdirectory( SimpleTests/MatrixTests )
add_subdirectory( SimpleTests/MeshTests )
if(NOT MSVC AND BLAS_FOUND AND LAPACK_FOUND)
add_subdirectory( SimpleTests/SolverTests )
endif()
endif()
endif() # OGS_BUILD_TESTS
# The configuration must be called from the source dir and not BaseLib/.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BaseLib/BuildInfo.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/BaseLib/BuildInfo.cpp" @ONLY)
include(scripts/cmake/MarkVariablesAdvanced.cmake)