-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
245 lines (200 loc) · 8.43 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
############ Project setup ##################################################
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
#############################################################################
set (CMAKE_CXX_STANDARD 17)
include( ${CMAKE_SOURCE_DIR}/base/config/tools.cmake )
include( ${CMAKE_SOURCE_DIR}/base/config/prebuilt_binaries.cmake )
include( ${CMAKE_SOURCE_DIR}/base/config/integration_tests_dir.cmake )
Plato_no_src_build()
# Advertise that we support shared libs (cmake squawks otherwise)
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
# Add ccache if available
find_program(CCACHE_FOUND ccache)
if( CCACHE_FOUND )
# Spack is able to use ccache, however, using ccache with nvcc_wrapper does not seem to work
# properly through spack.
message( STATUS "Found ccache" )
set( CMAKE_CXX_COMPILER_LAUNCHER ccache )
endif()
##################################################################
## Load config.cmake ##
##################################################################
if( DEFINED CONFIG )
message(STATUS "-DCONFIG specified: " ${CONFIG})
if( EXISTS ${CMAKE_BINARY_DIR}/${CONFIG} )
include( ${CMAKE_BINARY_DIR}/${CONFIG} )
else()
message(FATAL_ERROR "The configuration file '${CONFIG}' specified with -DCONFIG doesn't exist")
endif()
else()
if( EXISTS ${CMAKE_BINARY_DIR}/config.cmake )
include( ${CMAKE_BINARY_DIR}/config.cmake )
else()
message(STATUS "A configuration file named 'config.cmake' was not provided in the build directory.")
message(STATUS "Using command line arguments only to configure build.")
include( ${CMAKE_SOURCE_DIR}/base/config/defaults.cmake )
endif()
endif()
if( DEFINED PLATO_SYSTEM_CONFIG )
if( EXISTS ${PLATO_SYSTEM_CONFIG} )
include( ${PLATO_SYSTEM_CONFIG} )
else()
message(STATUS "Specified system configuration file ($PLATO_SYSTEM_CONFIG} not found")
message(FATAL_ERROR " ")
endif()
endif()
###############################################################################
###############################################################################
project(PlatoEngine LANGUAGES CXX C)
find_package(MPI REQUIRED COMPONENTS CXX)
############################ Trilinos Setup #################################
###############################################################################
IF (DEFINED TRILINOS_INSTALL_DIR)
SET(CMAKE_PREFIX_PATH ${TRILINOS_INSTALL_DIR} ${CMAKE_PREFIX_PATH})
ENDIF()
FIND_PACKAGE(Trilinos REQUIRED)
MESSAGE("\nFound Trilinos! Here are the details: ")
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
MESSAGE("End of Trilinos details\n")
########################### Compiler setup ###################################
message("Trilinos_CXX_COMPILER ${Trilinos_CXX_COMPILER}")
message("Trilinos_C_COMPILER ${Trilinos_C_COMPILER}")
message("Trilinos_Fortran_COMPILER ${Trilinos_Fortran_COMPILER}")
set(CMAKE_CXX_COMPILER ${Trilinos_CXX_COMPILER})
set(CMAKE_C_COMPILER ${Trilinos_C_COMPILER})
set(CMAKE_Fortran_COMPILER ${Trilinos_Fortran_COMPILER})
if(PLATOENGINE_ENABLE_CUDA)
message(STATUS "Enabling CUDA")
enable_language(CUDA)
endif()
########################### Compiler commands setup ###########################
if(CMAKE_EXPORT_COMPILE_COMMANDS)
file(CREATE_LINK "${CMAKE_BINARY_DIR}/compile_commands.json" "${CMAKE_SOURCE_DIR}/compile_commands.json" SYMBOLIC )
endif()
###############################################################################
###############################################################################
if( DAKOTADRIVER )
find_package(Dakota REQUIRED)
endif()
find_package(Boost REQUIRED COMPONENTS serialization filesystem system program_options regex mpi)
########################### Compiler setup ###################################
####################### (post 'project()' command) ############################
set(GCC_ADDITIONAL_WARNINGS -Wall
-Wextra
-Wshadow
-Wnon-virtual-dtor
-Wsuggest-override
-pedantic
-Wno-return-type-c-linkage
-Wno-unknown-warning-option)
if(BUILD_WITH_SANITIZER_FLAGS)
message(STATUS "Compiling with sanitizer flags turned on")
set(SANITIZER_FLAGS -fsanitize=address
-fno-omit-frame-pointer
-fsanitize=undefined
-fno-sanitize-recover=all
-fsanitize=float-divide-by-zero
-fsanitize=float-cast-overflow
-fsanitize=null
-fno-sanitize=alignment
-fsanitize=enum)
message(STATUS "Sanitizer flags: ${SANITIZER_FLAGS}")
add_compile_options(${SANITIZER_FLAGS})
add_link_options(${SANITIZER_FLAGS})
endif()
message("Trilinos_CXX_COMPILER_FLAGS: ${Trilinos_CXX_COMPILER_FLAGS}")
# set(CMAKE_C_FLAGS "${Trilinos_C_COMPILER_FLAGS} -fPIC -fopenmp")
# set(CMAKE_CXX_FLAGS "${Trilinos_CXX_COMPILER_FLAGS} -fPIC -fopenmp")
set(CMAKE_C_FLAGS "${Trilinos_C_COMPILER_FLAGS} -fPIC -Werror")
set(CMAKE_CXX_FLAGS "${Trilinos_CXX_COMPILER_FLAGS} -fPIC -Werror ")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${GCC_ADDITIONAL_WARNINGS}>")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
############################## gtest Setup ####################################
###############################################################################
if( UNIT_TESTING )
find_package(GTest REQUIRED)
endif()
if( ESP_ENABLED )
Plato_find_lib ( ESP_LIB ON egads ${ESP_LIB_DIR} )
Plato_find_lib ( OCSM_LIB ON ocsm ${ESP_LIB_DIR} )
Plato_find_path( ESP_INC ON egads.h ${ESP_INC_DIR} )
include_directories( ${ESP_INC} )
endif()
###############################################################################
###############################################################################
if("${CMAKE_BUILD_TYPE}" STREQUAL Release)
add_definitions( -DNDEBUG)
elseif("${CMAKE_BUILD_TYPE}" STREQUAL Debug)
endif()
if( STK_ENABLED )
message( "-- Compiling with STK " )
add_definitions( -DSTK_ENABLED )
endif()
if( ESP_ENABLED )
message( "-- Compiling with ESP " )
add_definitions( -DESP_ENABLED )
endif()
if( DAKOTADRIVER )
message( "-- Compiling Dakota Driver " )
add_definitions(-DDAKOTADRIVER)
endif()
if( ENABLE_ISO )
message( "-- Compiling PlatoIso " )
add_definitions(-DENABLE_ISO)
endif()
if( ENABLE_PRUNE )
message( "-- Compiling Plato prune and refine " )
add_definitions(-DENABLE_PRUNE)
endif()
if( REGRESSION OR UNIT_TESTING )
enable_testing()
endif()
if( AMFILTER_ENABLED )
message( "-- Compiling AMFilter, c++14 required " )
string(REPLACE "-std=c++11" "-std=c++14" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "-std=c++11" "-std=c++14" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "-std=c++11" "-std=c++14" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
add_definitions(-DAMFILTER_ENABLED)
find_package(ArborX REQUIRED)
set(PLATO_LIBRARIES ${PLATO_LIBRARIES} ArborX::ArborX)
endif()
add_subdirectory(base)
add_subdirectory(apps)
add_subdirectory(functional)
include(CMakePackageConfigHelpers)
install(EXPORT PlatoEngine NAMESPACE PlatoEngine FILE PlatoEngineTargets.cmake DESTINATION cmake)
configure_package_config_file(PlatoEngineConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/PlatoEngineConfig.cmake INSTALL_DESTINATION cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PlatoEngineConfig.cmake DESTINATION cmake)
install(EXPORT PlatoEngine NAMESPACE PlatoEngine:: FILE PlatoEngineTargets.cmake DESTINATION cmake)
if( REGRESSION )
integration_tests_dir()
if( PLATOMAIN )
add_integration_test(support_structure)
add_integration_test(su2_to_exodus)
if( PLATOPROXY )
add_integration_test(proxy)
endif()
if( PLATOSTATICS )
add_integration_test(platostatics)
endif()
if( ENABLE_PRUNE )
add_integration_test(prune_and_refine)
endif()
if( SIERRA_TESTS_ENABLED )
install_prebuilt_binaries()
add_integration_test(sierra)
endif()
if( SIERRA_TESTS_ENABLED AND DAKOTADRIVER )
add_integration_test(dakota_sierra)
endif()
if( OPTIMISM_TESTS_ENABLED )
add_integration_test(optimism)
endif()
else()
message("-- !! -- PlatoMain is required for regression testing.")
message("-- !! -- Regression has not been enabled.")
endif()
endif()
add_subdirectory(share)