-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
133 lines (108 loc) · 2.92 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
cmake_minimum_required(VERSION 2.8)
project(CLUE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "../parrotscmake")
## Compiler settings
message(STATUS "CMAKE_SYSTEM_NAME: " ${CMAKE_SYSTEM_NAME})
message(STATUS "CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID})
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(NEWCXX_ENABLED_FLAG "-std=c++11 -stdlib=libc++ -Wall -O2")
else()
set(NEWCXX_ENABLED_FLAG "-std=c++11 -Wall -Wno-mismatched-tags -O2")
endif()
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
set(NEWCXX_ENABLED_FLAG "-std=c++11 -Wall -O2")
else()
message(FATAL_ERROR, "Only GCC and clang is supported for now.")
endif()
set(CMAKE_CXX_FLAGS ${NEWCXX_ENABLED_FLAG})
message(STATUS "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed ${CMAKE_EXE_LINKER_FLAGS}")
enable_testing()
###################################
#
# Dependencies
#
###################################
## Google Test
find_package(GTest REQUIRED)
if (GTEST_FOUND)
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
message(STATUS "GTest Libraries: " ${GTEST_LIBRARIES})
endif()
# pthread library is required for Google Test to work properly
find_package(Threads REQUIRED)
###################################
#
# Directories
#
###################################
include_directories(include)
set(TESTS tests)
set(EXECUTABLE_OUTPUT_PATH bin)
###################################
#
# Unit testing
#
###################################
set(UNIT_TESTS
test_misc
test_predicates
test_optional
test_string_view
test_stringex
test_mparser
test_sformat
test_stemplate
test_type_name
test_value_range
test_array_view
test_reindexed_view
test_fast_vector
test_ordered_dict
test_keyed_vector
test_meta
test_meta_seq
test_textio
test_include_all
)
foreach (tname ${UNIT_TESTS})
add_executable(${tname} ${TESTS}/${tname}.cpp)
target_link_libraries(${tname} ${GTEST_BOTH_LIBRARIES})
target_link_libraries(${tname} ${CMAKE_THREAD_LIBS_INIT})
add_test(NAME ${tname} COMMAND ${tname})
endforeach()
set(THREADING_TESTS
test_shared_mutex
test_concurrent_counter
test_concurrent_queue
test_thread_pool
)
foreach(tname ${THREADING_TESTS})
add_executable(${tname} ${TESTS}/${tname}.cpp)
target_link_libraries(${tname} ${CMAKE_THREAD_LIBS_INIT})
add_test(NAME ${tname} COMMAND ${tname})
endforeach()
###################################
#
# Examples
#
###################################
set(EXAMPLES
ex_stopwatch
ex_timing
ex_strings
ex_mparser
)
set(THREAD_EXAMPLES
ex_cccounter
ex_ccqueue
ex_threadpool
)
foreach (name ${EXAMPLES})
add_executable(${name} examples/${name}.cpp)
endforeach()
foreach (name ${THREAD_EXAMPLES})
add_executable(${name} examples/${name}.cpp)
target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
endforeach()