-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
105 lines (90 loc) · 3.56 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
cmake_minimum_required(VERSION 3.9...3.12)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.12)
endif()
project(hermes-2 LANGUAGES CXX)
# Extra CMake scripts in cmake/ subdirectory
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# Update submodules
# Adapted from https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} -c submodule.recurse=false submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
# Get the Git revision
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC HERMES_REVISION)
if(HERMES_REVISION STREQUAL "GITDIR-NOTFOUND")
set(HERMES_REVISION "Unknown")
endif()
message(STATUS "Git revision: ${HERMES_REVISION}")
# BOUT++ is a dependency
add_subdirectory(external/BOUT-dev)
set(HERMES_SOURCES
src/hermes-2.cxx
include/hermes-2.hxx
src/diffusion2d.cxx
include/diffusion2d.hxx
src/div_ops.cxx
include/div_ops.hxx
src/full-velocity.cxx
include/full-velocity.hxx
src/loadmetric.cxx
include/loadmetric.hxx
src/mixed.cxx
include/mixed.hxx
src/neutral-model.cxx
include/neutral-model.hxx
include/none.hxx
src/radiation.cxx
include/radiation.hxx
src/recycling.cxx
include/recycling.hxx
atomicpp/ImpuritySpecies.cxx
atomicpp/ImpuritySpecies.hxx
atomicpp/json.hxx
atomicpp/Prad.cxx
atomicpp/Prad.hxx
atomicpp/RateCoefficient.cxx
atomicpp/RateCoefficient.hxx
atomicpp/sharedFunctions.cxx
atomicpp/sharedFunctions.hxx
)
# The main executable target
add_executable(hermes-2
${HERMES_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/include/revision.hxx)
target_link_libraries(hermes-2 PRIVATE bout++::bout++)
target_include_directories(hermes-2 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/atomicpp>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/atomicpp>
$<INSTALL_INTERFACE:include>
)
# Build the file containing just the commit hash
# This will be rebuilt on every commit!
configure_file(
"${PROJECT_SOURCE_DIR}/include/revision.hxx.in"
"${PROJECT_BINARY_DIR}/include/revision.hxx")
# Once built, copy the data and test directories
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/linear-device $<TARGET_FILE_DIR:${PROJECT_NAME}>/linear-device)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/json_database $<TARGET_FILE_DIR:${PROJECT_NAME}>/json_database)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/impurity_user_input.json $<TARGET_FILE_DIR:${PROJECT_NAME}>/impurity_user_input.json)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/tokamak $<TARGET_FILE_DIR:${PROJECT_NAME}>/tokamak)