-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
151 lines (122 loc) · 3.61 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
cmake_minimum_required(VERSION 3.1)
project(cmpth CXX)
option(CMPTH_ENABLE_MTH "Build MassiveThreads" ON)
option(CMPTH_ENABLE_MLOG "Use MassiveLogger" OFF)
option(CMPTH_ENABLE_ABT "Build Argobots" OFF)
add_library(cmpth INTERFACE)
target_include_directories(cmpth INTERFACE ./include)
install(DIRECTORY include/ DESTINATION include)
set(CMPTH_GLOBAL_CFLAGS -ftls-model=initial-exec)
# CMPTH_GLOBAL_CFLAGS will be used in massivethreads.cmake and argobots.cmake
add_library(cmpth-options INTERFACE)
target_compile_options(cmpth-options INTERFACE
-Wall -Wextra -pedantic ${CMPTH_GLOBAL_CFLAGS}
$<$<CXX_COMPILER_ID:Intel>:-wd2196> # Disable warning #2196: routine is both "inline" and "noinline"
)
function(cmpth_require_cxx11 target)
set_target_properties(${target} PROPERTIES
CXX_STANDARD 11
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON)
endfunction()
if(NOT APPLE)
add_library(cmpth-cfibre
./src/cfibre.cpp
)
target_link_libraries(cmpth-cfibre
cmpth
cmpth-options
)
cmpth_require_cxx11(cmpth-cfibre)
endif()
add_library(doctest INTERFACE)
target_include_directories(doctest INTERFACE
./external/doctest/doctest
)
add_executable(cmpth_test_sct
./tests/test_sct.cpp
)
target_link_libraries(cmpth_test_sct
cmpth
cmpth-options
doctest
)
cmpth_require_cxx11(cmpth_test_sct)
enable_testing()
add_test(
NAME cmpth_test_sct
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_sweep.sh
CMPTH_NUM_WORKERS $<TARGET_FILE:cmpth_test_sct>
)
if (${CMPTH_ENABLE_MTH})
include(./cmake/massivethreads.cmake)
target_link_libraries(cmpth INTERFACE massivethreads)
add_executable(cmpth_test_mth
./tests/test_mth.cpp
)
target_link_libraries(cmpth_test_mth
cmpth
cmpth-options
doctest
)
cmpth_require_cxx11(cmpth_test_mth)
add_test(
NAME cmpth_test_mth
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_sweep.sh
MYTH_NUM_WORKERS $<TARGET_FILE:cmpth_test_mth>
)
add_executable(cmpth_test_ctmth
./tests/test_ctmth.cpp
)
target_link_libraries(cmpth_test_ctmth
cmpth
cmpth-options
doctest
)
cmpth_require_cxx11(cmpth_test_ctmth)
add_test(
NAME cmpth_test_ctmth
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_sweep.sh
MYTH_NUM_WORKERS $<TARGET_FILE:cmpth_test_ctmth>
)
endif()
if (${CMPTH_ENABLE_MLOG})
add_library(massivelogger INTERFACE)
target_include_directories(massivelogger INTERFACE ./external/massivelogger/include)
target_link_libraries(cmpth INTERFACE massivelogger)
endif()
if (${CMPTH_ENABLE_ABT})
include(./cmake/argobots.cmake)
add_executable(cmpth-abt-test
./example/abt/abt-test.cpp
)
target_link_libraries(cmpth-abt-test
cmpth
cmpth-options
argobots
)
cmpth_require_cxx11(cmpth-abt-test)
endif()
add_library(cmpth-all INTERFACE)
target_link_libraries(cmpth-all INTERFACE
cmpth
$<$<BOOL:${CMPTH_ENABLE_ABT}>:argobots>
)
target_compile_definitions(cmpth-all INTERFACE
$<$<BOOL:${CMPTH_ENABLE_ABT}>:CMPTH_ENABLE_ABT=1>
)
if (${CMPTH_ENABLE_MTH}) # TODO
file(GLOB example_files example/*.cpp)
foreach(example_path IN LISTS example_files)
get_filename_component(example_name ${example_path} NAME_WE)
add_executable(cmpth-${example_name}
${example_path}
)
target_link_libraries(cmpth-${example_name}
cmpth-all
cmpth-options
doctest
)
cmpth_require_cxx11(cmpth-${example_name})
endforeach()
endif()