-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
185 lines (161 loc) · 7.11 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
#
# Copyright 2016 Erik Zenker
#
# This file is part of Graybat.
#
# Graybat is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Graybat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Graybat.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
# Graybat examples and tests
###############################################################################
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
project("graybat examples and tests")
###############################################################################
# MODULES
###############################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/utils/cmake/modules/")
###############################################################################
# Google Benchmark
###############################################################################
find_package(benchmark)
if(${benchmark_FOUND})
include_directories(${benchmark_INCLUDE_DIRS})
set(LIBS ${LIBS} ${benchmark_LIBRARIES})
endif(${benchmark_FOUND})
###############################################################################
# Boost
###############################################################################
find_package(Boost 1.61.0 COMPONENTS unit_test_framework program_options REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
###############################################################################
# Graybat
###############################################################################
find_package(graybat 1.0.0 REQUIRED CONFIG PATHS ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${graybat_INCLUDE_DIRS})
set(LIBS ${LIBS} ${graybat_LIBRARIES})
###############################################################################
# Compiler Flags
###############################################################################
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wvla-extension")
endif()
###############################################################################
# CCache
###############################################################################
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
###############################################################################
# Targets
###############################################################################
# Benchmark
file(GLOB BENCHMARKS test/benchmark/*.cpp)
add_executable(benchmark ${BENCHMARKS} ${graybat_GENERATED_FILES})
target_link_libraries(benchmark ${LIBS})
# Test cases
file(GLOB INTEGRATION_TESTS test/integration/*.cpp)
add_executable(check ${INTEGRATION_TESTS} ${graybat_GENERATED_FILES})
target_compile_definitions(check PRIVATE ${graybat_DEFINITIONS})
target_link_libraries(check ${LIBS})
add_test(graybat_check_build "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target check)
add_test(graybat_test_run_2_peers mpiexec -n 2 check )
set_tests_properties(graybat_test_run_2_peers PROPERTIES DEPENDS graybat_check_build)
file(GLOB UNIT_TESTS test/unit/main.cpp test/unit/*Tests.cpp)
add_executable(unit_tests ${UNIT_TESTS} ${graybat_GENERATED_FILES})
target_link_libraries(unit_tests ${LIBS})
add_test(graybat_unit_tests_build "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target unit_tests)
add_test(graybat_unit_tests_run unit_tests )
set_tests_properties(graybat_unit_tests_run PROPERTIES DEPENDS graybat_unit_tests_build)
# Fast testing
#file(GLOB TESTSFAST test/integration/main.cpp test/unit/ThreadPoolTests.cpp)
#add_executable(checkFast EXCLUDE_FROM_ALL ${TESTSFAST} ${graybat_GENERATED_FILES})
#set_property(TARGET checkFast PROPERTY CXX_STANDARD 14)
#target_link_libraries(checkFast ${LIBS})
# Examples
if(graybat_BMPI_CP_ENABLED)
add_custom_target(example)
file(GLOB EXAMPLES example/*.cpp)
foreach(EXAMPLE ${EXAMPLES})
get_filename_component(DEP ${EXAMPLE} NAME_WE)
add_executable(${DEP} ${EXAMPLE} ${graybat_GENERATED_FILES})
set_property(TARGET ${DEP} PROPERTY CXX_STANDARD 14)
target_link_libraries(${DEP} LINK_INTERFACE_LIBRARIES graybat)
target_link_libraries(${DEP} ${LIBS})
add_dependencies(example ${DEP})
endforeach(EXAMPLE)
add_test(graybat_example_build "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target example)
add_test(graybat_gol_run mpiexec gol 90 4 )
add_test(graybat_pr_run mpiexec pagerank )
set_tests_properties(graybat_gol_run PROPERTIES DEPENDS graybat_example_build)
set_tests_properties(graybat_pr_run PROPERTIES DEPENDS graybat_example_build)
endif()
# GRPC signaling server
if(graybat_ZMQ_CP_ENABLED)
add_executable( signaling utils/signaling_server.cpp ${graybat_GENERATED_FILES})
set_property(TARGET signaling PROPERTY CXX_STANDARD 11)
target_link_libraries(signaling ${LIBS})
endif()
# CTest
enable_testing()
# Install
file(GLOB CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake")
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
DESTINATION "lib/graybat"
)
install(
FILES ${CMAKE_FILES}
DESTINATION "lib/graybat"
)
if(graybat_ZMQ_CP_ENABLED)
install( TARGETS signaling
RUNTIME DESTINATION "bin"
)
endif()
# Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen." VERBATIM
)
endif(DOXYGEN_FOUND)
###############################################################################
# Clion Integration
###############################################################################
file(GLOB_RECURSE _SOURCES_PRE "*")
foreach(P ${_SOURCES_PRE})
# Remove dot-directories and the build directory
if(NOT ${P} MATCHES "${CMAKE_CURRENT_LIST_DIR}/([.].*/.*|build/.*)")
set(_SOURCES ${_SOURCES} ${P})
endif()
endforeach()
ADD_LIBRARY(CLION_DUMMY_TARGET EXCLUDE_FROM_ALL ${_SOURCES})