-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
153 lines (140 loc) · 4.09 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
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --versionh
cmake_minimum_required(VERSION 3.10)
include("Config.cmake")
# set the project name
project(GraAda3D)
set (CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
find_package(OpenMP REQUIRED)
message("${CMAKE_CXX_COMPILER_ID}")
message("Compiler command: $ENV{CXX}")
message("Openmp flag ${OpenMP_CXX_FLAGS}")
message("Installation location: ${CMAKE_INSTALL_PREFIX}/bin")
# if (DEFINED ENV{USE_NETCDF})
# message("USE_NETCDF=$ENV{USE_NETCDF}; The netcdf library will be included.")
# endif()
if (${USE_NETCDF})
message("USE_NETCDF=${USE_NETCDF}; The netcdf library will be included.")
endif()
if (${USE_MKL})
message("USE_MKL=${USE_MKL}; $ENV{MKLROOT}; MKL will be used.")
endif()
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#message("${CMAKE_CXX_COMPILER}")
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message("Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
# Forward modelling code
add_library(Forward_obj OBJECT
src/Forward_modelling/Cell.cpp
src/Forward_modelling/Fwd.cpp
src/Forward_modelling/Face.cpp
src/Forward_modelling/GravFormula.cpp
src/Forward_modelling/Integral.cpp
src/Forward_modelling/Mesh.cpp
src/Forward_modelling/Observation.cpp
src/Forward_modelling/Point.cpp
src/Forward_modelling/RectPrism.cpp)
target_include_directories(Forward_obj
PUBLIC
src/Forward_modelling
3rd_party_lib/boost_1_72_0
3rd_party_lib/eigen
3rd_party_lib/Linterp
3rd_party_lib/Timer
#if netcdf library is used
$<$<BOOL:${USE_NETCDF}>:
3rd_party_lib/netcdf/netcdf-cxx4-4.3.1
3rd_party_lib/netcdf/netcdf-c-4.7.4
>
)
target_link_libraries(Forward_obj
PUBLIC
OpenMP::OpenMP_CXX
$<$<BOOL:${USE_NETCDF}>:netcdf_c++4>
gsl
gslcblas
)
target_compile_options(Forward_obj
PUBLIC
-Wfatal-errors
${OpenMP_CXX_FLAGS}
)
target_compile_definitions(Forward_obj
PUBLIC
$<$<CXX_COMPILER_ID:Intel>:USE_MKL>
$<$<BOOL:${USE_NETCDF}>:USE_NETCDF>
)
# inversion code
add_library(Inversion_obj OBJECT
src/Inversion/InversionBase.cpp
src/Inversion/AdaptiveInversion.cpp
src/Inversion/LinearInversion.cpp
src/Inversion/GaussNewtonInversion.cpp)
target_include_directories(Inversion_obj
PUBLIC
src/Inversion
)
target_link_libraries(Inversion_obj
PUBLIC
Forward_obj
)
############################################################
# Create an executable
############################################################
add_executable(GraAda3D
src/GraAda3D.cpp
)
target_include_directories(GraAda3D
PRIVATE
src/Forward_modelling
src/Inversion
)
target_link_options(GraAda3D
PRIVATE
$<$<BOOL:${USE_MKL}>:-L$ENV{MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl>
)
target_link_libraries(GraAda3D
PRIVATE
Forward_obj
Inversion_obj
)
add_executable(Test_ordering
src/Test_ordering.cpp)
target_link_libraries(Test_ordering
PRIVATE
Forward_obj
Inversion_obj
)
add_executable(Synthetic_data1
src/Synthetic_data1.cpp)
target_link_libraries(Synthetic_data1
PRIVATE
Forward_obj
Inversion_obj
)
add_executable(test_wavelet_forward1
src/test_wavelet_forward1.cpp)
target_link_libraries(test_wavelet_forward1
PRIVATE
Forward_obj
Inversion_obj
)
add_executable(test_wavelet_forward2
src/test_wavelet_forward2.cpp)
target_link_libraries(test_wavelet_forward2
PRIVATE
Forward_obj
Inversion_obj
)
install(TARGETS GraAda3D Synthetic_data1
)