-
Notifications
You must be signed in to change notification settings - Fork 76
/
CMakeLists.txt
338 lines (274 loc) · 10.8 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# Copyright (c) 2017-2018 Hartmut Kaiser
# Copyright (c) 2018 R. Tohid
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.11.0)
# explicitly set certain policies
cmake_policy(VERSION 3.11.0)
################################################################################
# Build type (needs to be handled before project command below)
################################################################################
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Configuration type (one of Debug, RelWithDebInfo, Release, MinSizeRel)")
endif()
################################################################################
# project metadata
################################################################################
project(Phylanx C CXX)
set(PHYLANX_MAJOR_VERSION 0)
set(PHYLANX_MINOR_VERSION 0)
set(PHYLANX_PATCH_LEVEL 1)
set(PHYLANX_VERSION "${PHYLANX_MAJOR_VERSION}.${PHYLANX_MINOR_VERSION}.${PHYLANX_PATCH_LEVEL}")
set(PHYLANX_LIBRARY_VERSION "${PHYLANX_VERSION}")
set(PHYLANX_SOVERSION ${PHYLANX_MAJOR_VERSION})
set(PHYLANX_PACKAGE_NAME Phylanx)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
################################################################################
# CMake configuration
################################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
################################################################################
# Set basic search paths for Phylanx
################################################################################
include_directories("${PROJECT_SOURCE_DIR}")
link_directories(${CMAKE_BINARY_DIR}/lib)
# Debug library postfix
set(CMAKE_DEBUG_POSTFIX "d")
set(PHYLANX_DEBUG_POSTFIX "d")
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
include(CMakeDependentOption)
# include additional macro definitions
include(Phylanx_Utils)
phylanx_force_out_of_tree_build(
"This project requires an out-of-source-tree build. See README.rst. "
"Clean your CMake cache and CMakeFiles if this message persists.")
if(NOT PHYLANX_CMAKE_LOGLEVEL)
set(PHYLANX_CMAKE_LOGLEVEL "WARN")
endif()
################################################################################
# print initial diagnostics
phylanx_info("CMake version: " ${CMAKE_VERSION})
phylanx_info("Phylanx version: " ${PHYLANX_VERSION})
phylanx_detect_cpp_dialect()
# ##############################################################################
# C++ feature tests
# ##############################################################################
include(Phylanx_PerformCxxFeatureTests)
phylanx_perform_cxx_feature_tests()
################################################################################
# Locate HPX as we need to ensure to use at least the same C++ dialect as HPX uses
phylanx_setup_hpx()
################################################################################
# Special compiler flags
phylanx_setup_compiler_flags()
phylanx_setup_output_paths()
################################################################################
# Build options
phylanx_option(
PHYLANX_WITH_TASK_INLINING_POLICY BOOL
"Enable or disable the adaptive task inlining policy"
OFF ADVANCED CATEGORY "Build")
if(PHYLANX_WITH_TASK_INLINING_POLICY)
phylanx_add_config_define(PHYLANX_HAVE_TASK_INLINING_POLICY)
message("Adaptive task inlining policy enabled.")
endif()
phylanx_option(
PHYLANX_WITH_TESTS_BENCHMARKS BOOL
"Enable or disable the compilation of benchmark tests"
ON ADVANCED CATEGORY "Build")
phylanx_option(
PHYLANX_WITH_TESTS_REGRESSIONS BOOL
"Enable or disable the compilation of regression tests"
ON ADVANCED CATEGORY "Build")
phylanx_option(
PHYLANX_WITH_TESTS_UNIT BOOL
"Enable or disable the compilation of unit tests"
ON ADVANCED CATEGORY "Build")
phylanx_option(
PHYLANX_WITH_EXAMPLES BOOL
"Enable or disable the compilation of the examples"
ON ADVANCED CATEGORY "Build")
phylanx_option(
PHYLANX_WITH_DOCUMENTATION BOOL
"Enable or disable building Documentation"
OFF ADVANCED CATEGORY "Build")
phylanx_option(
PHYLANX_WITH_TOOLS BOOL
"Enable or disable building tools"
OFF ADVANCED CATEGORY "Build")
phylanx_option(
PHYLANX_WITH_HIGHFIVE BOOL
"Enable or disable building HDF5 Support"
OFF ADVANCED CATEGORY "Build")
phylanx_option(
PHYLANX_WITH_VIM_YCM BOOL
"Enable or disable YouCompleteMe configuration support for VIM"
OFF ADVANCED CATEGORY "Build")
phylanx_option(
PHYLANX_WITH_ITERATIVE_SOLVERS BOOL
"Enable or disable the Blaze iterative solvers"
OFF ADVANCED CATEGORY "Build")
if(MSVC)
phylanx_option(PHYLANX_WITH_PSEUDO_DEPENDENCIES BOOL
"Force creating pseudo targets and pseudo dependencies (default OFF)."
OFF CATEGORY "Build Targets")
else()
phylanx_option(PHYLANX_WITH_PSEUDO_DEPENDENCIES BOOL
"Force creating pseudo targets and pseudo dependencies (default ON)."
ON CATEGORY "Build Targets")
endif()
# Locate remaining dependencies
phylanx_setup_blaze()
phylanx_setup_pybind11()
phylanx_setup_highfive()
phylanx_include(GitCommit)
################################################################################
# Set basic search paths for the generated Phylanx headers
################################################################################
include_directories("${CMAKE_BINARY_DIR}")
################################################################################
# Target specification
# Recurse into some subdirectories. This does not actually cause another cmake
# executable to run. The same process will walk through the project's entire
# directory structure.
add_phylanx_pseudo_target(core)
add_subdirectory(src)
if(PHYLANX_WITH_EXAMPLES)
add_phylanx_pseudo_target(examples)
include_directories(examples)
add_subdirectory(examples)
endif()
################################################################################
# Targets related to Python (must come before tests)
add_subdirectory(python)
phylanx_export_targets(${phylanx_targets})
foreach(target ${phylanx_targets})
add_phylanx_pseudo_dependencies(core ${target})
endforeach()
###############################################################################
# Must come after Python
if(PHYLANX_WITH_DOCUMENTATION)
add_subdirectory(docs)
endif()
###############################################################################
# Tests
if(PHYLANX_WITH_TESTS_BENCHMARKS OR PHYLANX_WITH_TESTS_REGRESSIONS OR PHYLANX_WITH_TESTS_UNIT)
find_package(PythonInterp)
if(NOT PYTHONINTERP_FOUND)
phylanx_warn("A python interpreter could not be found. The test suite can not be run automatically.")
endif()
add_phylanx_pseudo_target(tests)
enable_testing()
include(CTest)
if(NOT MSVC)
find_program(CTEST_EXECUTABLE "ctest")
add_custom_command(TARGET tests POST_BUILD
COMMAND ${CTEST_EXECUTABLE} --output-on-failure --timeout 100 -C $<CONFIG>)
set_target_properties(tests
PROPERTIES FOLDER "Tests")
endif()
include_directories(tests)
add_subdirectory(tests)
endif()
# Configure phylanxrun.py
if(HPX_WITH_PARCELPORT_MPI)
find_package(MPI QUIET)
endif(HPX_WITH_PARCELPORT_MPI)
configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/phylanxrun.py.in"
"${CMAKE_BINARY_DIR}/bin/phylanxrun.py"
@ONLY)
################################################################################
# Targets related to Tools
if(PHYLANX_WITH_TOOLS)
add_phylanx_pseudo_target(tools)
add_subdirectory(tools)
endif()
################################################################################
# Configure the header to include all compile definitions
################################################################################
################################################################################
# PHYLANX_PREFIX
# The prefix is the default search path for Phylanx plugins
################################################################################
if("${PHYLANX_PLATFORM_UC}" STREQUAL "ANDROID")
set(PHYLANX_PREFIX "lib")
set(PHYLANX_BUILD_PREFIX "lib")
else()
set(PHYLANX_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(PHYLANX_BUILD_PREFIX "${CMAKE_BINARY_DIR}")
endif()
# Generate a defines.hpp to be used in the build directory ...
set(PHYLANX_DEFINES_PREFIX ${PHYLANX_BUILD_PREFIX})
phylanx_write_config_defines_file(
TEMPLATE "${PROJECT_SOURCE_DIR}/cmake/templates/config_defines.hpp.in"
NAMESPACE default
FILENAME "${CMAKE_BINARY_DIR}/phylanx/config/defines.hpp")
# Generate a defines.hpp to be used in the install directory ...
set(PHYLANX_DEFINES_PREFIX ${PHYLANX_PREFIX})
phylanx_write_config_defines_file(
TEMPLATE "${PROJECT_SOURCE_DIR}/cmake/templates/config_defines.hpp.in"
NAMESPACE default
FILENAME "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/phylanx/config/defines.hpp")
################################################################################
# installation instructions
################################################################################
install(
FILES "${CMAKE_BINARY_DIR}/bin/phylanxrun.py"
DESTINATION bin
COMPONENT core
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# Install all Phylanx header files
install(
DIRECTORY phylanx/
DESTINATION include/phylanx
COMPONENT core
FILES_MATCHING PATTERN "*.hpp"
PATTERN ".git" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "CTestFiles" EXCLUDE)
# Install all Phylanx header that have been configured using various
# cmake options
install(
DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/phylanx/"
DESTINATION include/phylanx
COMPONENT core
FILES_MATCHING PATTERN "*.hpp"
PATTERN ".git" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "CTestFiles" EXCLUDE)
# Install all Phylanx cmake utility files
install(
DIRECTORY cmake/
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PHYLANX_PACKAGE_NAME}
COMPONENT core
PATTERN ".in" EXCLUDE
PATTERN ".git" EXCLUDE)
install(
FILES "${PROJECT_SOURCE_DIR}/LICENSE_1_0.txt"
DESTINATION share/phylanx-${PHYLANX_VERSION}
COMPONENT license)
# install phylanx docs
if(PHYLANX_WITH_DOCUMENTATION)
# Install Phylanx documentation files
install(
FILES "${PROJECT_SOURCE_DIR}/docs/index.html"
DESTINATION ${CMAKE_INSTALL_DATADIR}/phylanx/ OPTIONAL
COMPONENT docs)
install(
DIRECTORY "${CMAKE_BINARY_DIR}/share/phylanx/docs/html/"
DESTINATION ${CMAKE_INSTALL_DATADIR}/phylanx/docs/html OPTIONAL
COMPONENT docs
PATTERN ".git" EXCLUDE)
endif()
phylanx_include(GeneratePackage)
# Create a symlink in share pointing to the latest Phylanx installation
# create_symbolic_link("${CMAKE_BINARY_DIR}/share/phylanx-${PHYLANX_VERSION}"
# "${CMAKE_BINARY_DIR}/share/phylanx")
message("")
message("Phylanx will be installed to ${CMAKE_INSTALL_PREFIX}")
message("")