-
Notifications
You must be signed in to change notification settings - Fork 34
/
CMakeLists.txt
157 lines (134 loc) · 5.03 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
cmake_minimum_required(VERSION 3.18.4)
# configure cmake to use the same compilers/flags as petsc
include(config/petscCompilers.cmake)
# Set the project details
project(ablateLibrary VERSION 0.12.34)
# Load the Required 3rd Party Libaries
pkg_check_modules(PETSc REQUIRED IMPORTED_TARGET GLOBAL PETSc)
# Set the c/c++ Standards
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Load the cmake required libraries
include(FetchContent) # FetContent will allow downloading of other libraries
include(GNUInstallDirs) # make cache variables for install destinations
# Check if we should enable testing options
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
include(CTest)
endif ()
# Create the library for ablate
add_library(ablateLibrary SHARED)
# Load in the subdirectories for the ablate library
add_subdirectory(src)
# find and load required libraries
include(config/cmakeFunctions.cmake)
include(config/findKokkos.cmake)
include(config/findYamlCpp.cmake)
include(config/findChrestCompilerFlags.cmake)
include(config/findCppParser.cmake)
include(config/findMuParser.cmake)
include(config/findXdmfGenerator.cmake)
include(config/findTChem.cmake)
include(config/findZerork.cmake)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
include(config/findOpenCascade.cmake)
include(config/findJson.cmake)
include(config/findTensorFlow.cmake)
include(config/findSLEPc.cmake)
include(config/printVersion.cmake)
find_package(HDF5 REQUIRED)
# specify in the required libaries
target_link_libraries(ablateLibrary
PUBLIC
PkgConfig::PETSc
slepc
CHREST::cppParserLibrary
yaml-cpp
muparser
CHREST::xdmfGeneratorLibrary
TChem::tchem
Tines::tines
Threads::Threads
nlohmann_json::nlohmann_json
${HDF5_LIBRARIES}
ZERORK::zerork_cfd_plugin
PRIVATE
chrestCompilerFlags)
# depending upon the build, we may need to add blas
find_package(BLAS)
if (BLAS_FOUND)
target_link_libraries(ablateLibrary
PUBLIC
BLAS::BLAS)
endif ()
#set ROCm libraries
if(DEFINED ENV{ABLATE_GPU})
if($ENV{ABLATE_GPU} STREQUAL "ROCM")
target_link_directories(ablateLibrary
PUBLIC
$ENV{ROCM_PATH}/lib)
endif ()
endif ()
# Set the ablate library requirements
set_property(TARGET ablateLibrary PROPERTY CXX_EXTENSIONS ON)
set_property(TARGET ablateLibrary PROPERTY CMAKE_CXX_STANDARD_REQUIRED ON)
set_property(TARGET ablateLibrary PROPERTY CXX_STANDARD 17)
set_property(TARGET ablateLibrary PROPERTY CXX_VISIBILITY_PRESET default)
# Setup and configure testing
if (BUILD_TESTING)
enable_testing()
include(GoogleTest)
include(config/findGoogleTest.cmake)
add_subdirectory(tests)
# Include the format command only if we are building tests
include(config/clangFormatter.cmake)
endif ()
# keep a separate main statement
add_executable(ablate main.cpp)
target_link_libraries(ablate PUBLIC ablateLibrary PRIVATE chrestCompilerFlags)
# include system specific hacks
include(config/systemHacks.cmake)
# install the cppParserLibrary (and others) target and create export-set
install(TARGETS ablate ablateLibrary muparser nlohmann_json cppParserLibrary yaml-cpp xdmfGeneratorLibrary chrestCompilerFlags
EXPORT ablateTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
set_target_properties(ablate PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
# install header file(s)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.hpp")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
update_header_paths_for_install(ablateLibrary ${PROJECT_SOURCE_DIR}/src ${CMAKE_INSTALL_INCLUDEDIR})
# generate and install export file
install(EXPORT ablateTargets
FILE ablateTargets.cmake
NAMESPACE CHREST::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ablate
)
# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ablateConfigVersion.cmake"
VERSION "${CMAKE_PROJECT_VERSION}"
COMPATIBILITY AnyNewerVersion
)
# create config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/config/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/ablateConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ablate
)
# install config files
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/ablateConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/ablateConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ablate
)
# generate the export targets for the build tree
export(EXPORT ablateTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/ablateTargets.cmake"
NAMESPACE CHREST::
)