~mardy/unity-scopes-api/clientid-1554040

1 by Michi Henning
Initial commit.
1
cmake_minimum_required(VERSION 2.8.10)
2
3
# Default install location. Must be set here, before setting the project.
4
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
5
    set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "" FORCE)
6
endif()
7
163.13.2 by Michi Henning
scoperegistry allows extra scopes to be added on the command line now:
8
set(PROJECT unity-scopes-api)
9
project(${PROJECT} C CXX)
1 by Michi Henning
Initial commit.
10
11
if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
12
   message(FATAL_ERROR "In-tree build attempt detected, aborting. Set your build dir outside your source dir, delete CMakeCache.txt from source root and try again.")
13
endif()
14
63.3.1 by Jussi Pakkanen
Clang usability updates.
15
include(CheckCXXSourceCompiles)
16
CHECK_CXX_SOURCE_COMPILES("#ifdef __clang__\n#else\n#error \"Not clang.\"\n#endif\nint main(int argc, char **argv) { return 0; }" IS_CLANG)
1 by Michi Henning
Initial commit.
17
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
18
63.3.1 by Jussi Pakkanen
Clang usability updates.
19
if(IS_CLANG)
20
  message(STATUS "Compiling with Clang, disabling lttng.")
21
endif()
22
1 by Michi Henning
Initial commit.
23
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lowercase but sometimes they are not.
24
163.225.4 by Michi Henning
Added "none" to accepted build types.
25
set(ACCEPTED_BUILD_TYPES "" none release debug relwithdebinfo coverage)
163.225.3 by Michi Henning
Fixed problem with build type check if CMAKE_BUILD_TYPE is the empty string.
26
list(FIND ACCEPTED_BUILD_TYPES "${cmake_build_type_lower}" IS_BUILD_TYPE_ACCEPTED)
163.225.2 by Michi Henning
Added check for invalid CMAKE_BUILD_TYPE, so we don't get tripped
27
if(${IS_BUILD_TYPE_ACCEPTED} EQUAL -1)
28
  message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}\nValid types are: ${ACCEPTED_BUILD_TYPES}")
29
endif()
30
1 by Michi Henning
Initial commit.
31
# Static C++ checks
32
6.1.1 by Michi Henning
Added warning if cppcheck isn't found.
33
find_program(CPPCHECK_COMMAND NAMES cppcheck)
34
if (CPPCHECK_COMMAND)
35
    set(CPPCHECK_COMMAND_OPTIONS --check-config --inline-suppr --enable=all -q --error-exitcode=2)
54.2.1 by Jussi Pakkanen
Quote the quoted.
36
    set(CPPCHECK_COMMAND_OPTIONS ${CPPCHECK_COMMAND_OPTIONS} --template "'{file}({line}): {severity} ({id}): {message}'")
6.1.1 by Michi Henning
Added warning if cppcheck isn't found.
37
    add_custom_target(cppcheck COMMAND ${CPPCHECK_COMMAND} ${CPPCHECK_COMMAND_OPTIONS}
38
        ${CMAKE_SOURCE_DIR}/src
39
        ${CMAKE_SOURCE_DIR}/test
40
        ${CMAKE_BINARY_DIR}/test
41
    )
42
else()
43
    message(WARNING "Cannot find cppcheck: cppcheck target will not be available")
44
endif()
1 by Michi Henning
Initial commit.
45
46
#
47
# Definitions for testing with valgrind.
48
#
49
50
configure_file(CTestCustom.cmake.in CTestCustom.cmake) # Tests in CTestCustom.cmake are skipped for valgrind
51
52
find_program(MEMORYCHECK_COMMAND NAMES valgrind)
53
if (MEMORYCHECK_COMMAND)
54
    set(MEMORYCHECK_COMMAND_OPTIONS
55
        "--suppressions=${CMAKE_SOURCE_DIR}/valgrind-suppress --leak-check=full --num-callers=40 --error-exitcode=3"
56
    )
57
    add_custom_target(valgrind DEPENDS NightlyMemCheck)
58
else()
59
    message(WARNING "Cannot find valgrind: valgrind target will not be available")
60
endif()
61
62
include(FindPkgConfig)
163.362.1 by Michi Henning
Stage 1 of logging. Added simple logger to the run time (scoped by the run time)
63
find_package(Boost COMPONENTS system filesystem regex serialization thread log REQUIRED)
163.140.1 by Michal Hruby
Use localized variants for some config key fields
64
pkg_check_modules(UNITY_API libunity-api>=0.1.3 REQUIRED)
207.1.1 by Pete Woods
Switch to using libapparmor instead of aa-exec binary
65
pkg_check_modules(PROCESS_CPP process-cpp>=1.0.1 REQUIRED)
66
pkg_check_modules(APPARMOR REQUIRED libapparmor REQUIRED)
40.4.13 by Marcus Tomlinson
Added check for LTTng tools -used in SimpleTracepoint_test to test trace reports.
67
pkg_check_modules(LTTNG_UST lttng-ust REQUIRED)
68
pkg_check_modules(LIBURCU_BP liburcu-bp REQUIRED)
163.228.6 by Michi Henning
Added SettingsSchema class with tests.
69
pkg_check_modules(JSONCPP jsoncpp REQUIRED)
176.1.13 by Marcus Tomlinson
Process chucked data from server as it arrives in HttpClientNetCpp
70
pkg_check_modules(LIBACCOUNTS libaccounts-glib REQUIRED)
71
pkg_check_modules(LIBSIGNON libsignon-glib REQUIRED)
163.343.1 by Michi Henning
Changed CMakeLists.txt to locate libzmq using pkg-config instead of find_library().
72
pkg_check_modules(ZMQLIB libzmq REQUIRED)
176.1.15 by Marcus Tomlinson
Reverted net-cpp 1.2.0 change
73
pkg_check_modules(NET_CPP net-cpp REQUIRED)
163.228.6 by Michi Henning
Added SettingsSchema class with tests.
74
176.1.12 by Marcus Tomlinson
Removed some more Qt stuff
75
find_library(ZMQPPLIB zmqpp)
76
if(NOT ZMQPPLIB)
176.1.13 by Marcus Tomlinson
Process chucked data from server as it arrives in HttpClientNetCpp
77
  message(FATAL_ERROR "libzmqpp-dev not found.")
176.1.12 by Marcus Tomlinson
Removed some more Qt stuff
78
endif()
79
80
find_library(CAPNPLIB capnp)
81
if(NOT CAPNPLIB)
176.1.13 by Marcus Tomlinson
Process chucked data from server as it arrives in HttpClientNetCpp
82
  message(FATAL_ERROR "libcapnp-dev not found.")
176.1.12 by Marcus Tomlinson
Removed some more Qt stuff
83
endif()
84
85
find_library(KJLIB kj)
86
if(NOT KJLIB)
176.1.13 by Marcus Tomlinson
Process chucked data from server as it arrives in HttpClientNetCpp
87
  message(FATAL_ERROR "capnproto not found.")
176.1.12 by Marcus Tomlinson
Removed some more Qt stuff
88
endif()
89
90
find_library(DLLIB dl)
91
if(NOT DLLIB)
176.1.13 by Marcus Tomlinson
Process chucked data from server as it arrives in HttpClientNetCpp
92
  message(FATAL_ERROR "dl lib not found.")
176.1.12 by Marcus Tomlinson
Removed some more Qt stuff
93
endif()
94
40.4.13 by Marcus Tomlinson
Added check for LTTng tools -used in SimpleTracepoint_test to test trace reports.
95
find_program(LTTNG_EXECUTABLE lttng)
96
if (NOT LTTNG_EXECUTABLE)
97
    message(SEND_ERROR "Cannot find LTTng executable: ensure that lttng-tools is installed")
98
endif()
99
115.3.1 by Michi Henning
Added formatstyle target to CMakeLists.txt. This runs all source and
100
#
101
# Code style fixer. We put the code through astyle first because it makes some fixes that
102
# clang-format won't do (such as "char *p" -> "char* p"). But astyle messes up other things
103
# (particularly lambdas and assembly-style comments), which clang-format does right.
104
# So, we run clang-format after running astyle, which undoes the damage done by astyle
105
# without reverting desirable astyle fixes.
106
#
107
108
find_program(ASTYLE_COMMAND NAMES astyle)
109
if (NOT ASTYLE_COMMAND)
110
    message(WARNING "Cannot find astyle: formatcode target will not be available")
111
else()
159.1.1 by Michi Henning
Added formatcode script to build/tools to make it easy
112
    # astyle 2.03 creates DOS line endings, so we need to fix its output
113
    find_program(DOS2UNIX_COMMAND NAMES dos2unix)
114
    if (NOT DOS2UNIX_COMMAND)
115
        message(WARNING "Cannot find dos2unix: formatcode target will not be available")
116
    else()
163.364.1 by Michi Henning
Added clang-format-3.6 to the list of supported formatters.
117
        find_program(CLANG_FORMAT_COMMAND NAMES clang-format-3.6 clang-format-3.5)
159.1.1 by Michi Henning
Added formatcode script to build/tools to make it easy
118
        if (NOT CLANG_FORMAT_COMMAND)
119
            message(WARNING "Cannot find clang-format >= clang-format-3.5: formatcode target will not be available")
120
        endif()
115.3.1 by Michi Henning
Added formatstyle target to CMakeLists.txt. This runs all source and
121
    endif()
122
endif()
123
159.1.1 by Michi Henning
Added formatcode script to build/tools to make it easy
124
if (ASTYLE_COMMAND AND DOS2UNIX_COMMAND AND CLANG_FORMAT_COMMAND)
115.3.1 by Michi Henning
Added formatstyle target to CMakeLists.txt. This runs all source and
125
set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${fmt_h})
115.3.3 by Michi Henning
Removed incorrectx ALL from formatcode target.
126
    add_custom_target(formatcode
115.3.5 by Michi Henning
Moved code run astyle and clang-format into separate script.
127
                      ${PROJECT_SOURCE_DIR}/tools/format-files.sh ${PROJECT_SOURCE_DIR} ${ASTYLE_COMMAND} ${CLANG_FORMAT_COMMAND})
115.3.1 by Michi Henning
Added formatstyle target to CMakeLists.txt. This runs all source and
128
endif()
129
52.2.1 by Jussi Pakkanen
Make capnpc usable when it is installed to a non-root location.
130
find_program(CAPNPC_BIN capnpc)
131
if(NOT CAPNPC_BIN)
132
  message(FATAL_ERROR "Capnp compiler not found.")
133
endif()
134
set(CAPNPC_FLAGS "" CACHE STRING "Extra flags for capnpc.")
135
163.378.1 by Pete Woods
Multi-arch support - search paths now include GNU triplet as first option
136
add_definitions(
163.378.6 by Pete Woods
Don't need to run dpkg!
137
  -DDEB_HOST_MULTIARCH="${CMAKE_LIBRARY_ARCHITECTURE}"
163.378.1 by Pete Woods
Multi-arch support - search paths now include GNU triplet as first option
138
)
139
163.316.1 by Marcus Tomlinson
Added support for online accounts (via new OnlineAccountClient class)
140
set(OTHER_INCLUDE_DIRS ${OTHER_INCLUDE_DIRS} ${UNITY_API_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
141
                       ${JSONCPP_INCLUDE_DIRS} ${PROCESS_CPP_INCLUDE_DIRS} ${APPARMOR_INCLUDE_DIRS}
176.1.11 by Marcus Tomlinson
Removed smartscopes static lib
142
                       ${LIBACCOUNTS_INCLUDE_DIRS} ${LIBSIGNON_INCLUDE_DIRS} ${NET_CPP_INCLUDE_DIRS})
143
set(OTHER_LIBS ${OTHER_LIBS} ${UNITY_API_LDFLAGS} ${APPARMOR_LDFLAGS} ${LIBACCOUNTS_LIBRARIES}
144
               ${LIBSIGNON_LIBRARIES} ${Boost_LIBRARIES} ${JSONCPP_LDFLAGS} ${PROCESS_CPP_LDFLAGS}
145
               ${ZMQPPLIB} ${ZMQLIB_LDFLAGS} ${CAPNPLIB} ${KJLIB} ${DLLIB} ${NET_CPP_LDFLAGS} pthread)
1 by Michi Henning
Initial commit.
146
147
# Standard install paths
148
include(GNUInstallDirs)
149
150
include_directories(
89.5.10 by Jussi Pakkanen
Changed include directives to match what our users will use.
151
    include/
152
    ${CMAKE_BINARY_DIR}/include
29 by Michi Henning
Moved Slice files into src tree and removed top-level slice tree.
153
    ${CMAKE_BINARY_DIR}/src
1 by Michi Henning
Initial commit.
154
    ${OTHER_INCLUDE_DIRS}
155
)
156
163.246.1 by Michi Henning
Require g++-4.9.
157
# We require g++ 4.9, to avoid ABI breakage with earlier version.
158
# Note that this must match what is specifed in debian/control.
163.257.41 by Marcus Tomlinson
Updated symbols
159
set(cxx_version_required 4.9)
163.246.1 by Michi Henning
Require g++-4.9.
160
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
163.246.4 by thomas-voss
Allow different gcc micro versions
161
    if (NOT CMAKE_CXX_COMPILER_VERSION MATCHES "^${cxx_version_required}")
163.262.3 by Michi Henning
Merged devel.
162
        message(FATAL_ERROR "g++ version must be ${cxx_version_required}, found ${CMAKE_CXX_COMPILER_VERSION}!")
163.246.1 by Michi Henning
Require g++-4.9.
163
    endif()
164
endif()
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
165
73.1.1 by Jussi Pakkanen
Make -Werror an option on C compiler too.
166
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-variadic-macros -Wextra -fPIC")
40.4.1 by Marcus Tomlinson
Added EventLogger interface and LTTNG tracer implementation to unity-scopes-api. Actual tracepoints still to be inserted into code.
167
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
168
# By default, all symbols are visible in the library. We strip out things we don't
169
# want at link time, by running a version script (see unity-scopes.map and the
170
# setting of LINK_FLAGS below).
171
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default")
1 by Michi Henning
Initial commit.
172
275.5.1 by Michi Henning
Bunch of misceallanous fixes:
173
set(C_AND_CXX_WARNINGS "-pedantic -Wall -Wextra")
163.372.1 by Michi Henning
Added a bunch of compiler warnings to help us stay out of trouble.
174
175
# Some additional warnings not included by the general flags set above.
275.5.1 by Michi Henning
Bunch of misceallanous fixes:
176
set(EXTRA_C_WARNINGS "-Wcast-align -Wcast-qual -Wformat -Wredundant-decls -Wswitch-default")
177
set(EXTRA_CXX_WARNINGS "-Wnon-virtual-dtor -Wctor-dtor-privacy -Wold-style-cast")
178
179
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_AND_CXX_WARNINGS}")
180
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_WARNINGS}")
181
182
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_AND_CXX_WARNINGS}")
183
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_C_WARNINGS}")
184
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_WARNINGS}")
52.3.2 by Michi Henning
Update CMakeLists.txt for compilation with clang.
185
186
# -fno-permissive causes warnings with clang, so we only enable it for gcc
187
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
188
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-permissive")
189
endif()
1 by Michi Henning
Initial commit.
190
93.1.1 by Jussi Pakkanen
Use lowercased build type.
191
if ("${cmake_build_type_lower}" STREQUAL "release" OR "${cmake_build_type_lower}" STREQUAL "relwithdebinfo")
89.4.5 by Michi Henning
Re-instated option for Werror and incorporated Jussi's improvements.
192
    option(Werror "Treat warnings as errors" ON)
193
else()
194
    option(Werror "Treat warnings as errors" OFF)
195
endif()
196
171.3.1 by Michi Henning
Made it possible to exclude the IsolatedScope test with an option.
197
# Some tests are slow, so make it possible not to run them
126.3.1 by Jussi Pakkanen
Make it possible to not run headertests, which are slow.
198
# during day-to-day development.
171.3.1 by Michi Henning
Made it possible to exclude the IsolatedScope test with an option.
199
option(slowtests "Run slow tests" ON)
126.3.1 by Jussi Pakkanen
Make it possible to not run headertests, which are slow.
200
126.1.1 by Jussi Pakkanen
Make werror actually work.
201
if (${Werror})
89.4.5 by Michi Henning
Re-instated option for Werror and incorporated Jussi's improvements.
202
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
203
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
204
    if ("${cmake_build_type_lower}" STREQUAL "release" OR "${cmake_build_type_lower}" STREQUAL "relwithdebinfo")
205
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations")
206
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
207
    endif()
1 by Michi Henning
Initial commit.
208
endif()
209
102.2.4 by Michi Henning
Allowed sanitizer to be enabled for either clang or gcc. Legal options are "thread" and "address".
210
set(SANITIZER "" CACHE STRING "Build with -fsanitize=<value> (legal values: thread, address)")
102.2.1 by Michi Henning
Added CMake option to build with -fsanitize=thread.
211
102.2.4 by Michi Henning
Allowed sanitizer to be enabled for either clang or gcc. Legal options are "thread" and "address".
212
if ("${SANITIZER}" STREQUAL "")
213
    # Do nothing
214
elseif (${SANITIZER} STREQUAL "thread")
102.2.2 by Michi Henning
Added -fno-omit-frame-pointer for thread sanitizer for more detail.
215
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
102.2.4 by Michi Henning
Allowed sanitizer to be enabled for either clang or gcc. Legal options are "thread" and "address".
216
elseif (${SANITIZER} STREQUAL "address")
217
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
218
else()
219
    message(FATAL_ERROR "Invalid SANITIZER setting: ${SANITIZER}")
102.2.1 by Michi Henning
Added CMake option to build with -fsanitize=thread.
220
endif()
221
163.152.13 by Michi Henning
More tidy-up. Incorporated feedback from Michal.
222
# Scopes library name. Also used as a prefix in various places, and as a subdirectory
223
# name for installed files. Changing this will also require corresponding changes
224
# to the debian files.
225
set(UNITY_SCOPES_LIB unity-scopes)
64.3.2 by Michal Hruby
Clean up paths, fix tests
226
1 by Michi Henning
Initial commit.
227
# API version
163.278.16 by Pete Woods
Reverse merge: Changed SOVERSION to consist of ${UNITY_SCOPES_MAJOR}${UNITY_SCOPES_MINOR}
228
set(UNITY_SCOPES_MAJOR 0)
163.381.50 by Marcus Tomlinson
Updated changelog and RELEASE_NOTES.md
229
set(UNITY_SCOPES_MINOR 6)
163.384.18 by Michi Henning
Update micro version, changelog, and release notes.
230
set(UNITY_SCOPES_MICRO 14)
163.381.48 by Marcus Tomlinson
Unbreak ABI
231
set(UNITY_SCOPES_SOVERSION 3)
1 by Michi Henning
Initial commit.
232
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
233
# Version for testing, with all symbols visible
163.152.13 by Michi Henning
More tidy-up. Incorporated feedback from Michal.
234
set(UNITY_SCOPES_TEST_LIB ${UNITY_SCOPES_LIB}-test)
11.3.1 by Michi Henning
Added simple scope loader that starts up a scope, initializes it, and can be used to start and stop a scope.
235
1 by Michi Henning
Initial commit.
236
# All the libraries we need to link a normal executable that uses Unity scopes
36 by Michi Henning
Add client-side connection concentrator and invocation pool.
237
set(LIBS ${UNITY_SCOPES_LIB})
1 by Michi Henning
Initial commit.
238
163.309.1 by Michi Henning
Wait for queued oneway requests to be picked up by an invocation thread during shut-down, to avoid destroying the outgoing oneway queue while invocations are potentially still sitting there, waiting to be written to Zmq.
239
# Test version of ${UNITY_SCOPES_LIB}, with internal symbols visible
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
240
set(TESTLIBS ${UNITY_SCOPES_TEST_LIB})
11.3.1 by Michi Henning
Added simple scope loader that starts up a scope, initializes it, and can be used to start and stop a scope.
241
1 by Michi Henning
Initial commit.
242
# Library install prefix
12 by Michi Henning
Propagated changes from unity-api tree.
243
set(LIB_INSTALL_PREFIX lib/${CMAKE_LIBRARY_ARCHITECTURE})
120.3.1 by Jussi Pakkanen
Use CMake machinery for libdirs.
244
set(LIBDIR ${CMAKE_INSTALL_LIBDIR})
163.152.13 by Michi Henning
More tidy-up. Incorporated feedback from Michal.
245
246
set(LIBSUBDIR ${LIBDIR}/${UNITY_SCOPES_LIB}})
247
set(HDR_INSTALL_DIR include/${UNITY_SCOPES_LIB}-${UNITY_SCOPES_MAJOR})
2 by Michi Henning
Minor fixes to debian packaging. Fixed incorrect project name in CMakeLists.txt.
248
163.234.1 by Michi Henning
Fix compile flags so we get line numbers when building with coverage.
249
#####################################################################
250
# Enable code coverage calculation with gcov/gcovr/lcov
251
# Usage:
252
#  * Switch build type to coverage (use ccmake or cmake-gui)
253
#  * Invoke make, make test, make coverage (or ninja if you use that backend)
254
#  * Find html report in subdir coveragereport
255
#  * Find xml report suitable for jenkins in coverage.xml
256
#####################################################################
257
if(cmake_build_type_lower MATCHES coverage)
258
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -g")
259
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -g")
260
    set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage -g")
261
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage -g")
262
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage -g")
263
endif()
264
include(EnableCoverageReport)
265
1 by Michi Henning
Initial commit.
266
# Tests
267
include(CTest)
268
enable_testing()
269
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
270
# Add subdirectories.
163.6.2 by Jussi Pakkanen
Depend on headers only.
271
add_subdirectory(include)
1 by Michi Henning
Initial commit.
272
add_subdirectory(src)
52.3.5 by Michi Henning
Fixed scoperegistry to use new scoperunner and to figure out which scopes to run from config files.
273
add_subdirectory(scoperegistry)
274
add_subdirectory(scoperunner)
163.187.6 by Michi Henning
Increased wait time a little for Runtime test.
275
add_subdirectory(smartscopesproxy)
42.2.1 by Michal Hruby
Flatten directory structure
276
add_subdirectory(data)
1 by Michi Henning
Initial commit.
277
add_subdirectory(test)
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
278
add_subdirectory(demo)
159.1.1 by Michi Henning
Added formatcode script to build/tools to make it easy
279
add_subdirectory(tools)
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
280
31 by Michi Henning
Cautious first steps towards Zmq-based middleware. Object adapter mostly done, need to hook capnp-generated
281
# Custom rules to compile .capnp files
282
foreach(file ${CAPNPROTO_FILES})
283
284
    string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" build_dir ${file})
285
    get_filename_component(build_dir ${build_dir} PATH)
286
287
    get_filename_component(proto_file ${file} NAME)
288
    string(REPLACE ".capnp" ".capnp.c++" src_file ${proto_file})
289
    string(REPLACE ".capnp" ".capnp.h" hdr_file ${proto_file})
290
291
    set(src_file ${build_dir}/${src_file})
292
    set(hdr_file ${build_dir}/${hdr_file})
293
294
    set(CAPNPROTO_HDRS ${CAPNPROTO_HDRS} ${hdr_file})
295
    set(CAPNPROTO_SRC ${CAPNPROTO_SRC} ${src_file})
296
endforeach()
297
298
# cmake cannot analyze include file dependencies of .capnproto files, so the easiest option is to recompile
299
# all files if any one of them changes
300
add_custom_command(OUTPUT ${CAPNPROTO_SRC} ${CAPNPROTO_HDRS}
301
                   DEPENDS ${CAPNPROTO_FILES}
52.2.1 by Jussi Pakkanen
Make capnpc usable when it is installed to a non-root location.
302
                   COMMAND ${CAPNPC_BIN} ${CAPNPC_FLAGS} -oc++:${CMAKE_BINARY_DIR} --src-prefix=${CMAKE_SOURCE_DIR} ${CAPNPROTO_FILES})
29 by Michi Henning
Moved Slice files into src tree and removed top-level slice tree.
303
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
304
# Pseudo-library of object files. We need a version of the library for normal clients
305
# that does not expose symbols in the unity::scopes::internal namespace, and another
306
# version for whitebox tests, so we can write unit tests for classes in the internal namespaces.
307
# Here, we create an object library that then is used to link the normal and the test libraries.
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
308
309
set(UNITY_SCOPES_LIB_OBJ ${UNITY_SCOPES_LIB}-obj)
163.88.1 by Michi Henning
Added @cond/@endcond for benchmarking classes to suppress doxygen complaints.
310
add_library(${UNITY_SCOPES_LIB_OBJ} OBJECT ${UNITY_SCOPES_LIB_SRC} ${CAPNPROTO_SRC})
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
311
set_target_properties(${UNITY_SCOPES_LIB_OBJ} PROPERTIES COMPILE_FLAGS "-fPIC")
312
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
313
# Use the object files to make the normal library.
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
314
add_library(${UNITY_SCOPES_LIB} SHARED $<TARGET_OBJECTS:${UNITY_SCOPES_LIB_OBJ}>)
315
set_target_properties(${UNITY_SCOPES_LIB} PROPERTIES
163.45.85 by Michal Hruby
Added conflicts+replaces
316
    VERSION "${UNITY_SCOPES_MAJOR}.${UNITY_SCOPES_MINOR}.${UNITY_SCOPES_MICRO}"
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
317
    SOVERSION ${UNITY_SCOPES_SOVERSION}
318
)
63.3.1 by Jussi Pakkanen
Clang usability updates.
319
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
320
# Use the object files to make the test library.
321
add_library(${UNITY_SCOPES_TEST_LIB} SHARED $<TARGET_OBJECTS:${UNITY_SCOPES_LIB_OBJ}>)
322
set_target_properties(${UNITY_SCOPES_TEST_LIB} PROPERTIES
163.45.85 by Michal Hruby
Added conflicts+replaces
323
    VERSION "${UNITY_SCOPES_MAJOR}.${UNITY_SCOPES_MINOR}.${UNITY_SCOPES_MICRO}"
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
324
    SOVERSION ${UNITY_SCOPES_SOVERSION}
325
)
326
163.55.2 by Michi Henning
Fixed setting of target properties for library to not overwrite the -Wl,--no-undefined flag that might have
327
set(ldflags "")
328
63.3.1 by Jussi Pakkanen
Clang usability updates.
329
# Clang sanitizers don't work if --no-undefined is given as a linker argument.
330
if(NOT IS_CLANG)
163.55.2 by Michi Henning
Fixed setting of target properties for library to not overwrite the -Wl,--no-undefined flag that might have
331
    set(ldflags "-Wl,--no-undefined")
63.3.1 by Jussi Pakkanen
Clang usability updates.
332
endif()
333
163.55.2 by Michi Henning
Fixed setting of target properties for library to not overwrite the -Wl,--no-undefined flag that might have
334
set_target_properties(${UNITY_SCOPES_TEST_LIB} PROPERTIES LINK_FLAGS "${ldflags}")
335
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
336
# We compile with all symbols visible by default. For the shipping library, we strip
337
# out all symbols that (recursively) are in the unity::scopes::internal namespace,
338
# except for a few exceptions that are needed by the scoperegistry, scoperunner,
339
# smartscopesproxy, and any other binaries that reach into the internal namespace.
163.152.13 by Michi Henning
More tidy-up. Incorporated feedback from Michal.
340
set(symbol_map "${CMAKE_SOURCE_DIR}/${UNITY_SCOPES_LIB}.map")
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
341
set_target_properties(${UNITY_SCOPES_LIB} PROPERTIES
163.55.2 by Michi Henning
Fixed setting of target properties for library to not overwrite the -Wl,--no-undefined flag that might have
342
                      LINK_FLAGS "${ldflags} -Wl,--version-script,${symbol_map}")
343
set_target_properties(${UNITY_SCOPES_LIB} PROPERTIES LINK_DEPENDS ${symbol_map})
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
344
63.3.1 by Jussi Pakkanen
Clang usability updates.
345
target_link_libraries(${UNITY_SCOPES_LIB} ${OTHER_LIBS})
163.55.1 by Michi Henning
Added unity-scopes.map to (recursively) remove symbols in the unity::scopes::internal namespace.
346
target_link_libraries(${UNITY_SCOPES_TEST_LIB} ${OTHER_LIBS})
347
348
# Only the normal library gets installed.
11.4.1 by Michi Henning
Added main objects with Ice implementation: registry, query, reply.
349
install(TARGETS ${UNITY_SCOPES_LIB} LIBRARY DESTINATION ${LIB_INSTALL_PREFIX})
350
351
# Enable coverage testing
1 by Michi Henning
Initial commit.
352
353
if (cmake_build_type_lower MATCHES coverage)
287.2.1 by Michi Henning
Fixed coverage build.
354
  ENABLE_COVERAGE_REPORT(TARGETS ${UNITY_SCOPES_LIB}
163.328.11 by Michi Henning
Disabled coverage for demos and debian/tests.
355
                         FILTER /usr/include
356
                                ${CMAKE_SOURCE_DIR}/test/*
357
                                ${CMAKE_SOURCE_DIR}/debian/tests/*
358
                                ${CMAKE_SOURCE_DIR}/demo/*
359
                                ${CMAKE_BINARY_DIR}/*)
1 by Michi Henning
Initial commit.
360
endif()
361
362
#
363
# Documentation
364
#
42.1.3 by Pawel Stolowski
Use cmake option for DEVEL_DOCS.
365
# Pass -DDEVEL_DOCS=ON to cmake for more detailed documentation
366
367
option(DEVEL_DOCS "Enable detailed Doxygen documentation")
1 by Michi Henning
Initial commit.
368
369
find_package(Doxygen)
370
find_program(DOT_EXECUTABLE dot /usr/bin)
371
if (NOT DOXYGEN_FOUND OR NOT DOT_EXECUTABLE)
372
    message(WARNING "Cannot generate documentation: doxygen and/or graphviz not found")
373
else()
42.1.3 by Pawel Stolowski
Use cmake option for DEVEL_DOCS.
374
    if (DEVEL_DOCS)
142.2.2 by Jussi Pakkanen
Forward Doxygen warnings to a file instead.
375
      message(STATUS "Creating devel documentation")
42.1.1 by Pawel Stolowski
Added doxygen config file for creating detailed docs.
376
      configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile-devel.in ${PROJECT_BINARY_DIR}/doc/Doxyfile @ONLY IMMEDIATE)
377
    else()
378
      configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile.in ${PROJECT_BINARY_DIR}/doc/Doxyfile @ONLY IMMEDIATE)
379
    endif()
163.83.1 by Pawel Stolowski
Added an index.html that redirects to the real index, for convienience when working on documentation. It doesn't get installed.
380
    configure_file(${PROJECT_SOURCE_DIR}/doc/index.html ${PROJECT_BINARY_DIR}/doc/index.html COPYONLY)
163.152.13 by Michi Henning
More tidy-up. Incorporated feedback from Michal.
381
    add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc/${UNITY_SCOPES_LIB}/index.html
1 by Michi Henning
Initial commit.
382
                       COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/doc/Doxyfile
383
                       DEPENDS ${PROJECT_BINARY_DIR}/doc/Doxyfile
163.77.6 by Michi Henning
Added and fixed lots of doc comments. Added tutorial.dox to list of
384
                               ${PROJECT_SOURCE_DIR}/doc/tutorial.dox
1 by Michi Henning
Initial commit.
385
                               ${UNITY_SCOPES_LIB_SRC}
386
                               ${UNITY_SCOPES_LIB_HDRS})
142.2.3 by Jussi Pakkanen
Return ALL that got lost in the shuffle.
387
    add_custom_target(doc ALL
163.152.13 by Michi Henning
More tidy-up. Incorporated feedback from Michal.
388
                       DEPENDS ${PROJECT_BINARY_DIR}/doc/${UNITY_SCOPES_LIB}/index.html)
389
    install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/${UNITY_SCOPES_LIB}
390
            DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/doc)
163.220.48 by Pete Woods
Prepare for release
391
endif()