-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
233 lines (179 loc) · 7.42 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
cmake_minimum_required(VERSION 3.10)
if (NOT DEFINED ENABLE_FORTRAN)
set(ENABLE_FORTRAN ON)
endif (NOT DEFINED ENABLE_FORTRAN)
if (ENABLE_FORTRAN)
project(
typhon
VERSION 3.0.2
DESCRIPTION "Typhon is a distributed communications library for unstructured mesh applications."
LANGUAGES CXX Fortran
)
else (ENABLE_FORTRAN)
project(
typhon
VERSION 3.0.2
DESCRIPTION "Typhon is a distributed communications library for unstructured mesh applications."
LANGUAGES CXX
)
endif (ENABLE_FORTRAN)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if (NOT DEFINED BUILD_TYPHON_DUMP)
set(BUILD_TYPHON_DUMP OFF)
endif (NOT DEFINED BUILD_TYPHON_DUMP)
if (NOT DEFINED BUILD_DOCS)
set(BUILD_DOCS OFF)
endif (NOT DEFINED BUILD_DOCS)
# ------------------------------------------------------------------------------
# Get VCS info
# ------------------------------------------------------------------------------
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Add git info
add_definitions("-DTYPHON_GIT_BRANCH=${GIT_BRANCH}")
add_definitions("-DTYPHON_GIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
# ------------------------------------------------------------------------------
# Shared library
# ------------------------------------------------------------------------------
set(TYPHON_SRC
${PROJECT_SOURCE_DIR}/src/collect.cpp
${PROJECT_SOURCE_DIR}/src/decomposition.cpp
${PROJECT_SOURCE_DIR}/src/dt_reduce.cpp
${PROJECT_SOURCE_DIR}/src/exchange.cpp
${PROJECT_SOURCE_DIR}/src/keys.cpp
${PROJECT_SOURCE_DIR}/src/quantity.cpp
${PROJECT_SOURCE_DIR}/src/register.cpp
${PROJECT_SOURCE_DIR}/src/schedule.cpp
${PROJECT_SOURCE_DIR}/src/core.cpp
${PROJECT_SOURCE_DIR}/src/utilities.cpp
${PROJECT_SOURCE_DIR}/src/serialise.cpp
${PROJECT_SOURCE_DIR}/src/distribute.cpp
${PROJECT_SOURCE_DIR}/src/distribute/ns.cpp
${PROJECT_SOURCE_DIR}/src/distribute/element_cloud.cpp
${PROJECT_SOURCE_DIR}/src/distribute/node_cloud.cpp
${PROJECT_SOURCE_DIR}/src/distribute/layer_info.cpp
)
add_library(typhon SHARED ${TYPHON_SRC})
set_target_properties(typhon PROPERTIES VERSION ${PROJECT_VERSION})
set (TYPHON_PUBLIC_HEADERS "include/typhon.h")
set_target_properties(typhon PROPERTIES PUBLIC_HEADER "${TYPHON_PUBLIC_HEADERS}")
target_compile_features(typhon PRIVATE cxx_std_11)
target_compile_options(typhon PRIVATE -Wall -Wextra -pedantic)
target_include_directories(typhon PRIVATE include)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions("-DTYPHON_DEBUG")
endif (CMAKE_BUILD_TYPE MATCHES "Debug")
# ------------------------------------------------------------------------------
# Fortran module
# ------------------------------------------------------------------------------
if (ENABLE_FORTRAN)
target_sources(typhon PRIVATE ${PROJECT_SOURCE_DIR}/src/typhon.f90)
list (APPEND TYPHON_PUBLIC_HEADERS ${CMAKE_BINARY_DIR}/typhon.mod)
set_target_properties(typhon PROPERTIES PUBLIC_HEADER
"${TYPHON_PUBLIC_HEADERS}")
target_compile_options(typhon PRIVATE
$<$<COMPILE_LANGUAGE:Fortran>:-std=f2008>)
target_compile_options(typhon PRIVATE
$<$<COMPILE_LANGUAGE:Fortran>:-Wno-c-binding-type>)
endif (ENABLE_FORTRAN)
# ------------------------------------------------------------------------------
# Utility binary
# ------------------------------------------------------------------------------
if (BUILD_TYPHON_DUMP)
add_executable(
typhon_dump
${PROJECT_SOURCE_DIR}/src/typhon_dump.cpp)
set_target_properties(typhon_dump PROPERTIES VERSION ${PROJECT_VERSION})
target_link_libraries(typhon_dump PRIVATE typhon)
target_include_directories(typhon_dump PRIVATE include)
endif (BUILD_TYPHON_DUMP)
# ------------------------------------------------------------------------------
# MPI
# ------------------------------------------------------------------------------
set(MPI_CXX_SKIP_MPICXX "true")
if (ENABLE_FORTRAN)
find_package(MPI COMPONENTS CXX Fortran REQUIRED)
else (ENABLE_FORTRAN)
find_package(MPI COMPONENTS CXX REQUIRED)
endif (ENABLE_FORTRAN)
target_include_directories(typhon PUBLIC ${MPI_CXX_INCLUDE_DIRS})
target_link_libraries(typhon PUBLIC ${MPI_CXX_LIBRARIES})
if (ENABLE_FORTRAN)
target_include_directories(typhon PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
target_link_libraries(typhon PUBLIC ${MPI_Fortran_LIBRARIES})
endif (ENABLE_FORTRAN)
target_compile_options(typhon PUBLIC
$<$<COMPILE_LANGUAGE:CXX>:${MPI_CXX_COMPILE_OPTIONS}>)
set_target_properties(typhon PROPERTIES LINK_FLAGS ${MPI_CXX_LINK_FLAGS})
if (ENABLE_FORTRAN)
target_compile_options(typhon PUBLIC
$<$<COMPILE_LANGUAGE:Fortran>:${MPI_Fortran_COMPILE_OPTIONS}>)
set_target_properties(typhon PROPERTIES LINK_FLAGS
${MPI_Fortran_LINK_FLAGS})
endif (ENABLE_FORTRAN)
# ------------------------------------------------------------------------------
# yaml-cpp
# ------------------------------------------------------------------------------
if (BUILD_TYPHON_DUMP)
find_package(YamlCpp)
if (YamlCpp_FOUND)
add_definitions("-DTYPHON_YAMLCPP_SUPPORT")
target_include_directories(typhon_dump PRIVATE ${YamlCpp_INCLUDES})
target_link_libraries(typhon_dump PRIVATE ${YamlCpp_LIBRARIES})
target_sources(typhon_dump PRIVATE
${PROJECT_SOURCE_DIR}/src/yaml_output.cpp)
endif (YamlCpp_FOUND)
endif (BUILD_TYPHON_DUMP)
# ------------------------------------------------------------------------------
# Doxygen
# ------------------------------------------------------------------------------
if (BUILD_DOCS)
find_package(Doxygen REQUIRED)
# set input and output files
set(Doxygen_IN ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in)
set(Doxygen_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${Doxygen_IN} ${Doxygen_OUT} @ONLY)
# Note the option ALL which allows to build the docs together with the application
add_custom_target(doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${Doxygen_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif (BUILD_DOCS)
# ------------------------------------------------------------------------------
# Installation
# ------------------------------------------------------------------------------
include(GNUInstallDirs)
install(
TARGETS typhon
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if (BUILD_TYPHON_DUMP)
install(
TARGETS typhon_dump
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif (BUILD_TYPHON_DUMP)
# ------------------------------------------------------------------------------
# Tests
# ------------------------------------------------------------------------------
enable_testing()
add_subdirectory(test)
# ------------------------------------------------------------------------------
# Examples
# ------------------------------------------------------------------------------
add_subdirectory(examples)