Skip to content

Commit f8c7178

Browse files
committed
Some fixies
1 parent fe88246 commit f8c7178

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

CMakeLists.txt

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.0)
22
project(i3ipc++)
33

4+
OPTION(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
5+
46
SET(BUILD_STATIC_LIBS ON)
57
SET(BUILD_SHARED_LIBS OFF)
68
add_subdirectory(3rd/jsoncpp)
@@ -29,22 +31,24 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
2931
file(GLOB_RECURSE SRC src/*.cpp)
3032
add_library(i3ipc++_static STATIC ${SRC})
3133

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()
5054
endif()

0 commit comments

Comments
 (0)