-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
136 lines (111 loc) · 3.59 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
# which cmake versions
cmake_minimum_required(VERSION 3.11...3.23)
# project name and properties
project(
nuDust++
VERSION 0.1
DESCRIPTION "dust nucleation and kinetics"
LANGUAGES CXX)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(
FATAL_ERROR
"You are trying to configure a build in the source directory. Move to another directory and rerun cmake.\nTIP: It is common to do (from the top of the source dir):\n\t \" $> mkdir build && cd build; cmake ..\" "
)
endif()
option(NUDUSTC_ENABLE_OPENMP OFF "Use OpenMP for cell/particle parallelization")
option(NUDUSTC_ENABLE_MPI OFF "Use MPI for cell/particle parallelization")
option(NUDUSTC_USE_SUNDIALS OFF "Use sundials CVODE integrator")
# dependencies
list(APPEND BOOST_COMPONENTS program_options filesystem serialization)
find_package(Boost REQUIRED ${BOOST_COMPONENTS})
if(NUDUSTC_USE_SUNDIALS)
find_package(SUNDIALS 5.8 REQUIRED)
endif()
if(NUDUSTC_ENABLE_OPENMP)
find_package(OpenMP REQUIRED)
endif()
include(FetchContent)
FetchContent_Declare(
plog
GIT_REPOSITORY https://github.com/SergiusTheBest/plog.git
GIT_TAG 1.1.9)
FetchContent_MakeAvailable(plog)
option(NUDUSTC_BENCHMARK "Enable benchmark wrappers" OFF)
set(NUD_EXE "nudustc++")
set(NUD_SRCS
src/cell.cpp
src/cellobserver.cpp
src/configuration.cpp
src/main.cpp
src/network.cpp
src/nudust.cpp
src/reaction.cpp)
set(NUD_HEADERS
include/axis.h
include/cell.h
include/cellobserver.h
include/configuration.h
include/constants.h
include/elements.h
include/makima.h
include/network.h
include/nudust.h
include/reaction.h
include/sput_params.h
include/sputter.h
include/utilities.h)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(${NUD_EXE} ${NUD_SRCS} ${NUD_HEADERS})
target_include_directories(${NUD_EXE} PRIVATE ${PROJECT_SOURCE_DIR}/include)
set(with_mpi "$<BOOL:${NUDUSTC_ENABLE_MPI}>")
set(with_openmp "$<BOOL:${NUDUSTC_ENABLE_OPENMP}>")
set(use_sundials "$<BOOL:${NUDUSTC_USE_SUNDIALS}>")
if(NUDUSTC_ENABLE_MPI)
message("Looking for MPI")
find_package(MPI REQUIRED CXX)
include_directories(${MPI_CXX_INCLUDE_DIRS})
target_link_libraries(${NUD_EXE} PRIVATE ${MPI_CXX_LIBRARIES})
target_link_libraries(${NUD_EXE} PUBLIC MPI::MPI_CXX)
message("MPI Found")
endif()
if(NUDUSTC_USE_SUNDIALS)
target_link_libraries(${NUD_EXE} PRIVATE SUNDIALS::cvode SUNDIALS::nvecserial)
endif()
target_link_libraries(
${NUD_EXE}
PRIVATE Boost::headers
Boost::program_options
Boost::serialization
Boost::filesystem
plog::plog
$<${with_mpi}:MPI::MPI_CXX>
$<${with_openmp}:OpenMP::OpenMP_CXX>)
target_compile_definitions(
${NUD_EXE}
PRIVATE $<$<BOOL:${NUDUSTC_BENCHMARK}>:ENABLE_BENCHMARK>
$<$<BOOL:${NUDUSTC_ENABLE_MPI}>:NUDUSTC_ENABLE_MPI>
# latest boost fails with gcc@12
# https://github.com/boostorg/phoenix/issues/111
BOOST_PHOENIX_STL_TUPLE_H_)
add_custom_command(
TARGET ${NUD_EXE}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data/
$<TARGET_FILE_DIR:${NUD_EXE}>/data)
add_custom_command(
TARGET ${NUD_EXE}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
$<TARGET_FILE_DIR:${NUD_EXE}>/output)
add_custom_command(
TARGET ${NUD_EXE}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
$<TARGET_FILE_DIR:${NUD_EXE}>/restart)
# IDEs should put the headers in a nice place
source_group(
TREE "${PROJECT_SOURCE_DIR}/include"
PREFIX "Header Files"
FILES ${NUD_HEADERS})