-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
137 lines (116 loc) · 5.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
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0074 NEW)
project(pumgen LANGUAGES C CXX)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
option(SIMMETRIX "Use simmetrix libraries" OFF)
set(SIMMETRIX_ROOT "" CACHE STRING "Root directory of simmetrix dev files")
set(SIM_MPI "mpich3" CACHE STRING "MPI version used by simmetrix")
option(NETCDF "Use netcdf" OFF)
option(PARASOLID "enable support for parasolid files" OFF)
option(SCOREC "Use PUMI/APF" OFF)
set(LOG_LEVEL "info" CACHE STRING "Log level for the code")
set_property(CACHE LOG_LEVEL PROPERTY STRINGS "debug" "info" "warning" "error")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo") # MinSizeRel is useless for us
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
message(STATUS "Set build type to Release as none was supplied.")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
add_executable(pumgen
${CMAKE_CURRENT_SOURCE_DIR}/src/pumgen.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/meshreader/GambitReader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/meshreader/GMSH4Parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/input/ParallelVertexFilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/GMSHLexer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/GMSHParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/GMSH2Parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/aux/InsphereCalculator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/aux/MPIConvenience.cpp
)
target_include_directories(pumgen PUBLIC src
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_SOURCE_DIR}/submodules/"
)
if (PARASOLID)
target_compile_definitions(pumgen PUBLIC PARASOLID)
endif()
if (NETCDF)
find_package(NetCDF REQUIRED)
target_sources(pumgen PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/input/NetCDFPartition.cpp)
target_include_directories(pumgen PUBLIC ${NetCDF_INCLUDE_DIRS})
target_link_libraries(pumgen PUBLIC ${NetCDF_LIBRARY})
target_compile_definitions(pumgen PUBLIC USE_NETCDF)
set(INSTALL_RPATH "${NetCDF_LIBRARY_DIR}")
endif()
set(HDF5_PREFER_PARALLEL True)
find_package(HDF5 REQUIRED COMPONENTS C HL)
target_include_directories(pumgen PUBLIC ${HDF5_INCLUDE_DIRS})
target_link_libraries(pumgen PUBLIC ${HDF5_C_HL_LIBRARIES} ${HDF5_C_LIBRARIES})
target_compile_definitions(pumgen PUBLIC USE_HDF)
string(REPLACE "include" "lib" HDF5_LIBRARY_DIRS "${HDF5_INCLUDE_DIRS}")
set(INSTALL_RPATH "${HDF5_LIBRARY_DIRS}:${INSTALL_RPATH}")
find_package(OpenMP REQUIRED)
target_link_libraries(pumgen PUBLIC OpenMP::OpenMP_CXX)
find_package(MPI REQUIRED)
target_link_libraries(pumgen PUBLIC MPI::MPI_CXX)
target_compile_definitions(pumgen PUBLIC PARALLEL)
if (SCOREC)
find_package(APF REQUIRED)
target_include_directories(pumgen PUBLIC ${APF_INCLUDE_DIR})
target_link_libraries(pumgen PUBLIC ${APF_LIBRARIES})
target_compile_definitions(pumgen PUBLIC USE_SCOREC)
endif()
add_library(tinyxml2 submodules/tinyxml2/tinyxml2.cpp)
target_link_libraries(pumgen PUBLIC tinyxml2)
if (SIMMETRIX)
find_package(SIMMETRIX REQUIRED)
# easi
find_package(easi 1.0.0 REQUIRED)
target_link_libraries(pumgen PUBLIC easi::easi)
target_sources(pumgen PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/input/AnalysisAttributes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/input/EasiMeshSize.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/input/MeshAttributes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/input/split.cpp
)
target_compile_definitions(pumgen PUBLIC USE_SIMMOD)
if(${SIM_MAJOR_VER} LESS 11)
target_compile_definitions(pumgen PUBLIC BEFORE_SIM_11)
endif()
if(${SIM_MAJOR_VER} LESS 15)
target_compile_definitions(pumgen PUBLIC BEFORE_SIM_15)
endif()
if(${SIM_MAJOR_VER} LESS 18)
target_compile_definitions(pumgen PUBLIC BEFORE_SIM_18)
endif()
if(${SIM_MAJOR_VER} LESS 2024)
target_compile_definitions(pumgen PUBLIC BEFORE_SIM_2024)
endif()
target_include_directories(pumgen PUBLIC ${SIMMETRIX_INCLUDE_DIR})
target_link_libraries(pumgen PUBLIC ${SIMMETRIX_LIBRARIES})
endif()
function(cast_log_level_to_int log_level_str log_level_int)
if (${log_level_str} STREQUAL "debug")
set(${log_level_int} 3 PARENT_SCOPE)
elseif (${log_level_str} STREQUAL "info")
set(${log_level_int} 2 PARENT_SCOPE)
elseif (${log_level_str} STREQUAL "warning")
set(${log_level_int} 1 PARENT_SCOPE)
elseif (${log_level_str} STREQUAL "error")
set(${log_level_int} 0 PARENT_SCOPE)
endif()
endfunction()
cast_log_level_to_int(LOG_LEVEL LOG_LEVEL)
target_compile_definitions(pumgen PUBLIC LOG_LEVEL=${LOG_LEVEL})
if(SIMMETRIX)
set(INSTALL_RPATH "${SIM_PS_KRNL_LIB_DIR}:${INSTALL_RPATH}")
endif()
set_target_properties(pumgen PROPERTIES INSTALL_RPATH "${INSTALL_RPATH}")
install(TARGETS pumgen RUNTIME DESTINATION bin DESTINATION ${CMAKE_INSTALL_BINDIR})