forked from STEllAR-GROUP/hpx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
416 lines (368 loc) · 13 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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# Copyright (c) 2007-2017 Hartmut Kaiser
# Copyright (c) 2011 Bryce Lelbach
# Copyright (c) 2018 Nikunj Gupta
#
# 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)
add_subdirectory(components)
foreach(lib "hpx")
set(${lib}_SOURCES "" CACHE INTERNAL "Sources for lib${lib}." FORCE)
if(MSVC)
set(${lib}_HEADERS "" CACHE INTERNAL "Headers for lib${lib}." FORCE)
endif()
endforeach()
################################################################################
# gather sources
# libhpx sources
add_hpx_library_sources(hpx
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/*.cpp"
EXCLUDE "(.*(hpx_main|hpx_user).*[.]cpp)|main.cpp|hpx_wrap.cpp")
add_hpx_library_sources(hpx
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/pre_main.cpp"
APPEND)
add_hpx_library_sources(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/src/runtime/*.cpp"
APPEND)
add_hpx_library_sources(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/src/performance_counters/*.cpp"
APPEND)
add_hpx_library_sources(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/src/util/*.cpp"
EXCLUDE ".*lightweight_test.cpp"
APPEND)
add_hpx_library_sources(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/src/lcos/*.cpp"
APPEND)
add_hpx_library_sources(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/src/compute/*.cpp"
APPEND)
add_hpx_library_sources(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/src/compat/*.cpp"
APPEND)
# libhpx_wrap sources
if(HPX_WITH_DYNAMIC_HPX_MAIN AND ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
add_hpx_library_sources (hpx_Wrap
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
endif()
# libhpx_init sources
add_hpx_library_sources(hpx_init
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/hpx_*.cpp"
EXCLUDE "hpx_init[.]cpp|hpx_wrap.cpp")
add_hpx_library_sources(hpx_init
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/util/lightweight_test.cpp"
APPEND)
add_hpx_library_sources(hpx_init
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/main.cpp" APPEND)
set(hpx_external_SOURCES "" CACHE INTERNAL "Sources for libhpx_external." FORCE)
if(MSVC)
if(HPX_WITH_SWAP_CONTEXT_EMULATION)
set(switch_to_fiber_source
"${PROJECT_SOURCE_DIR}/src/runtime/threads/coroutines/switch_to_fiber.asm")
add_hpx_library_sources(hpx_external_objects
GLOB GLOBS "${switch_to_fiber_source}")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/switch_to_fiber.obj"
COMMAND "${CMAKE_ASM_MASM_COMPILER}" /Fo "${CMAKE_CURRENT_BINARY_DIR}/switch_to_fiber.obj" /nologo /c "${switch_to_fiber_source}"
DEPENDS "${switch_to_fiber_source}"
VERBATIM)
set(hpx_external_OBJECTS "${CMAKE_CURRENT_BINARY_DIR}/switch_to_fiber.obj"
CACHE INTERNAL "External object files for HPX." FORCE)
endif()
# add natvis files to solution (supported starting VS2015)
if(MSVC14)
add_hpx_library_sources(hpx_natvis_files
GLOB GLOBS "${PROJECT_SOURCE_DIR}/tools/VS/*.natvis")
set(hpx_external_OBJECTS ${hpx_external_OBJECTS} ${hpx_natvis_files_SOURCES})
source_group("Natvis Files" FILES ${hpx_natvis_files_SOURCES})
endif()
endif()
if("${HPX_PLATFORM_UC}" STREQUAL "ANDROID")
add_hpx_library_sources(hpx_external GLOB GLOBS "${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.c")
endif()
################################################################################
# gather headers
# libhpx headers
add_hpx_library_headers(hpx
GLOB GLOBS "${PROJECT_SOURCE_DIR}/hpx/*.hpp"
EXCLUDE ".*hpx_main.*[.]hpp")
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/runtime/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/config/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/include/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/lcos/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/performance_counters/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/traits/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/util/*.h*"
EXCLUDE "(.*_binary_.*|[io]chunk_.*)[.]hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB GLOBS "${PROJECT_SOURCE_DIR}/hpx/plugins/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/parallel/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/compute/*.hpp"
APPEND)
add_hpx_library_headers(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/hpx/compat/*.hpp"
APPEND)
if(HPX_WITH_STATIC_LINKING)
add_hpx_library_headers(hpx
GLOB GLOBS "${PROJECT_SOURCE_DIR}/hpx/components/*.hpp"
APPEND)
endif()
# libhpx_init headers
add_hpx_library_headers(hpx_init
GLOB GLOBS "${PROJECT_SOURCE_DIR}/hpx/hpx_main*.hpp")
################################################################################
# make source groups
add_hpx_source_group(
NAME hpx CLASS "Source Files"
ROOT "${PROJECT_SOURCE_DIR}/src"
TARGETS ${hpx_SOURCES})
add_hpx_source_group(
NAME hpx CLASS "External Source Files"
ROOT "${PROJECT_SOURCE_DIR}/external"
TARGETS ${hpx_external_SOURCES})
add_hpx_source_group(
NAME hpx
CLASS "Header Files"
ROOT "${PROJECT_SOURCE_DIR}/hpx"
TARGETS ${hpx_HEADERS})
if(HPX_WITH_DYNAMIC_HPX_MAIN AND ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
add_hpx_source_group(
NAME hpx_wrap
CLASS "Source Files"
ROOT "${PROECT_SOURCE_DIR}/src"
TARGETS "${PROECT_SOURCE_DIR}/src/hpx_wrap.cpp")
endif()
add_hpx_source_group(
NAME hpx_init
CLASS "Source Files"
ROOT "${PROJECT_SOURCE_DIR}/src"
TARGETS ${hpx_init_SOURCES})
add_hpx_source_group(
NAME hpx_init
CLASS "Header Files"
ROOT "${PROJECT_SOURCE_DIR}/hpx"
TARGETS ${hpx_init_HEADERS})
if(NOT HPX_WITH_STATIC_LINKING)
if(MSVC)
# The MSVC linker can't handle a static library as large as we get when
# statically linking the main HPX library
set(hpx_library_link_mode_core SHARED)
else()
set(hpx_library_link_mode_core ${hpx_library_link_mode})
endif()
endif()
# Add static parcelport sources ...
add_static_parcelports()
set(hpx_HEADERS ${hpx_HEADERS} ${HPX_STATIC_PARCELPORT_PLUGINS_HEADERS})
set(hpx_SOURCES ${hpx_SOURCES} ${HPX_STATIC_PARCELPORT_PLUGINS_SOURCES})
#
# set_source_files_properties and set_property appear to be broken when setting
# INCLUDE_DIRECTORIES, so work around by adding compile flags for the include
# locations needed by parcelport plugin sources
#
foreach(_plugin ${HPX_STATIC_PARCELPORT_PLUGINS})
if (_parcelport_${_plugin}_INCLUDE_DIRECTORIES)
string (REPLACE ";" " -I" _INCLUDE_STRING "${_parcelport_${_plugin}_INCLUDE_DIRECTORIES}")
set_property(
SOURCE
${_parcelport_${_plugin}_SOURCES}
APPEND_STRING PROPERTY COMPILE_FLAGS
" -I${_INCLUDE_STRING}"
)
endif()
endforeach()
################################################################################
# libhpx
if(HPX_WITH_STATIC_LINKING)
set(hpx_SOURCES ${hpx_SOURCES} ${hpx_init_SOURCES})
endif()
if(HPX_WITH_DEFAULT_TARGETS)
if(HPX_WITH_CUDA)
cuda_add_library(hpx ${hpx_library_link_mode_core}
${hpx_SOURCES} ${hpx_external_SOURCES} ${hpx_external_OBJECTS} ${hpx_HEADERS})
else()
add_library(hpx ${hpx_library_link_mode_core}
${hpx_SOURCES} ${hpx_external_SOURCES} ${hpx_external_OBJECTS} ${hpx_HEADERS})
endif()
else()
if(HPX_WITH_CUDA)
cuda_add_library(hpx ${hpx_library_link_mode_core} EXCLUDE_FROM_ALL
${hpx_SOURCES} ${hpx_external_SOURCES} ${hpx_external_OBJECTS} ${hpx_HEADERS})
else()
add_library(hpx ${hpx_library_link_mode_core} EXCLUDE_FROM_ALL
${hpx_SOURCES} ${hpx_external_SOURCES} ${hpx_external_OBJECTS} ${hpx_HEADERS})
endif()
endif()
#if(HPX_WITH_STATIC_LINKING)
# add_dependencies(hpx static_component_data_hpp)
#endif()
if("${HPX_PLATFORM_UC}" STREQUAL "ANDROID")
set_target_properties(hpx PROPERTIES
CLEAN_DIRECT_OUTPUT 1
OUTPUT_NAME hpx
FOLDER "Core")
else()
set_target_properties(hpx PROPERTIES
VERSION ${HPX_VERSION}
SOVERSION ${HPX_SOVERSION}
CLEAN_DIRECT_OUTPUT 1
OUTPUT_NAME hpx
FOLDER "Core")
endif()
target_link_libraries(hpx ${HPX_TLL_PUBLIC} ${HPX_LIBRARIES})
if(HPX_ADDITIONAL_RUNTIME_DEPENDENCIES)
target_link_libraries(hpx ${HPX_TLL_PUBLIC} ${HPX_ADDITIONAL_RUNTIME_DEPENDENCIES})
endif()
if(HPX_ADDITIONAL_PRIVATE_RUNTIME_DEPENDENCIES)
target_link_libraries(hpx ${HPX_TLL_PRIVATE} ${HPX_ADDITIONAL_PRIVATE_RUNTIME_DEPENDENCIES})
endif()
foreach(_plugin ${HPX_STATIC_PARCELPORT_PLUGINS})
if (_parcelport_${_plugin}_LIBRARIES)
target_link_libraries(hpx ${HPX_TLL_PUBLIC} ${_parcelport_${_plugin}_LIBRARIES})
hpx_export_targets(${_parcelport_${_plugin}_LIBRARIES})
endif()
endforeach()
set_property(TARGET hpx APPEND
PROPERTY COMPILE_DEFINITIONS
"HPX_COMPONENT_NAME=hpx"
"HPX_EXPORTS"
"HPX_ENABLE_ASSERT_HANDLER")
################################################################################
# Emulation of SwapContext on Windows
################################################################################
if(MSVC)
if(HPX_WITH_SWAP_CONTEXT_EMULATION)
set_property(TARGET hpx APPEND
PROPERTY LINK_FLAGS
"/EXPORT:switch_to_fiber")
endif()
endif()
set(hpx_targets ${hpx_targets} hpx)
################################################################################
# libhpx_init
if(NOT HPX_WITH_STATIC_LINKING)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(HPX_WITH_DEFAULT_TARGETS)
if(HPX_WITH_CUDA)
cuda_add_library(hpx_init STATIC
${hpx_init_SOURCES} ${hpx_init_HEADERS})
else()
add_library(hpx_init STATIC
${hpx_init_SOURCES} ${hpx_init_HEADERS})
endif()
else()
if(HPX_WITH_CUDA)
cuda_add_library(hpx_init STATIC EXCLUDE_FROM_ALL
${hpx_init_SOURCES} ${hpx_init_HEADERS})
else()
add_library(hpx_init STATIC EXCLUDE_FROM_ALL
${hpx_init_SOURCES} ${hpx_init_HEADERS})
endif()
endif()
set_property(TARGET hpx_init APPEND
PROPERTY COMPILE_DEFINITIONS
"HPX_APPLICATION_EXPORTS"
"HPX_ENABLE_ASSERT_HANDLER")
set_property(TARGET hpx_init PROPERTY FOLDER "Core")
set(hpx_targets ${hpx_targets} hpx_init)
endif()
get_property(HPX_TARGET_COMPILE_DEFINITIONS_VAR
GLOBAL PROPERTY HPX_TARGET_COMPILE_DEFINITIONS)
foreach(_flag ${HPX_TARGET_COMPILE_DEFINITIONS_VAR})
target_compile_definitions(hpx INTERFACE ${_flag})
target_compile_definitions(hpx PUBLIC ${_flag})
if(NOT HPX_WITH_STATIC_LINKING)
target_compile_definitions(hpx_init PUBLIC ${_flag})
endif()
endforeach()
################################################################################
# libhpx_wrap
if(HPX_WITH_DYNAMIC_HPX_MAIN AND ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
if(NOT HPX_WITH_STATIC_LINKING)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(HPX_WITH_DEFAULT_TARGETS)
if(HPX_WITH_CUDA)
cuda_add_library(hpx_wrap STATIC
"${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
else()
add_library(hpx_wrap STATIC
"${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
endif()
else()
if(HPX_WITH_CUDA)
cuda_add_library(hpx_wrap STATIC EXCLUDE_FROM_ALL
"${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
else()
add_library(hpx_wrap STATIC EXCLUDE_FROM_ALL
"${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
endif()
endif()
set_property(TARGET hpx_wrap APPEND
PROPERTY COMPILE_DEFINITIONS
"HPX_APPLICATION_EXPORTS"
"HPX_ENABLE_ASSERT_HANDLER")
set_property(TARGET hpx_wrap PROPERTY FOLDER "Core")
set(hpx_targets ${hpx_targets} hpx_wrap)
endif()
endif()
get_property(HPX_TARGET_COMPILE_DEFINITIONS_VAR
GLOBAL PROPERTY HPX_TARGET_COMPILE_DEFINITIONS)
foreach(_flag ${HPX_TARGET_COMPILE_DEFINITIONS_VAR})
target_compile_definitions(hpx INTERFACE ${_flag})
target_compile_definitions(hpx PUBLIC ${_flag})
if(HPX_WITH_DYNAMIC_HPX_MAIN AND ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
target_compile_definitions(hpx_wrap INTERFACE ${_flag})
target_compile_definitions(hpx_wrap PUBLIC ${_flag})
endif()
if(NOT HPX_WITH_STATIC_LINKING)
target_compile_definitions(hpx_init PUBLIC ${_flag})
endif()
endforeach()
get_property(HPX_TARGET_COMPILE_OPTIONS_VAR
GLOBAL PROPERTY HPX_TARGET_COMPILE_OPTIONS)
foreach(_flag ${HPX_TARGET_COMPILE_OPTIONS_VAR})
target_compile_options(hpx INTERFACE ${_flag})
target_compile_options(hpx PUBLIC ${_flag})
if(HPX_WITH_DYNAMIC_HPX_MAIN AND ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
target_compile_options(hpx_wrap INTERFACE ${_flag})
target_compile_options(hpx_wrap PUBLIC ${_flag})
endif()
if(NOT HPX_WITH_STATIC_LINKING)
target_compile_options(hpx_init PUBLIC ${_flag})
endif()
endforeach()
set(_optional)
if(HPX_WITH_DEFAULT_TARGETS)
set(_optional OPTIONAL)
endif()
install(
TARGETS
${hpx_targets}
EXPORT HPXTargets
LIBRARY DESTINATION ${LIB}
ARCHIVE DESTINATION ${LIB}
RUNTIME DESTINATION bin
COMPONENT runtime
${_optional}
)
hpx_export_targets(${hpx_targets})
foreach(target ${hpx_targets})
add_hpx_pseudo_dependencies(core ${target})
endforeach()