|
1 | 1 | cmake_minimum_required(VERSION 3.0) |
2 | 2 | project(i3ipc++) |
3 | 3 |
|
| 4 | +OPTION(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF) |
| 5 | + |
4 | 6 | SET(BUILD_STATIC_LIBS ON) |
5 | 7 | SET(BUILD_SHARED_LIBS OFF) |
6 | 8 | add_subdirectory(3rd/jsoncpp) |
@@ -29,22 +31,24 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") |
29 | 31 | file(GLOB_RECURSE SRC src/*.cpp) |
30 | 32 | add_library(i3ipc++_static STATIC ${SRC}) |
31 | 33 |
|
32 | | -SET(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR}) |
33 | | -SET(I3IPCpp_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/) |
34 | | -SET(I3IPCpp_LIBRARIES i3ipc++_static ${SIGCPP_LIBRARIES} jsoncpp_lib_static) |
35 | | - |
36 | | -find_package(CxxTest) |
37 | | -if(CXXTEST_FOUND) |
38 | | - include_directories(${CXXTEST_INCLUDE_DIR}) |
39 | | - include_directories(src/) |
40 | | - add_definitions( |
41 | | - -DTEST_SRC_ROOT="${CMAKE_CURRENT_SOURCE_DIR}/test" |
42 | | - ) |
43 | | - |
44 | | - enable_testing() |
45 | | - file(GLOB SRC_TEST test/*.hpp) |
46 | | - CXXTEST_ADD_TEST(i3ipcpp_check test.cpp ${SRC_TEST}) |
47 | | - target_link_libraries(i3ipcpp_check ${I3IPCpp_LIBRARIES}) |
48 | | -else() |
49 | | - message(WARNING "CxxTest not found. Unable to run unit-tests") |
| 34 | +SET(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) |
| 35 | +SET(I3IPCpp_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/ PARENT_SCOPE) |
| 36 | +SET(I3IPCpp_LIBRARIES i3ipc++_static ${SIGCPP_LIBRARIES} jsoncpp_lib_static PARENT_SCOPE) |
| 37 | + |
| 38 | +if(I3IPCpp_WITH_TESTS) |
| 39 | + find_package(CxxTest) |
| 40 | + if(CXXTEST_FOUND) |
| 41 | + include_directories(${CXXTEST_INCLUDE_DIR}) |
| 42 | + include_directories(src/) |
| 43 | + add_definitions( |
| 44 | + -DTEST_SRC_ROOT="${CMAKE_CURRENT_SOURCE_DIR}/test" |
| 45 | + ) |
| 46 | + |
| 47 | + enable_testing() |
| 48 | + file(GLOB SRC_TEST test/*.hpp) |
| 49 | + CXXTEST_ADD_TEST(i3ipcpp_check test.cpp ${SRC_TEST}) |
| 50 | + target_link_libraries(i3ipcpp_check ${I3IPCpp_LIBRARIES}) |
| 51 | + else() |
| 52 | + message(WARNING "CxxTest not found. Unable to run unit-tests") |
| 53 | + endif() |
50 | 54 | endif() |
0 commit comments