From f8c71782be8af274fabc0dafe14c57ff2dc2a60f Mon Sep 17 00:00:00 2001 From: Sergey Naumov Date: Tue, 29 Dec 2015 12:59:19 +0300 Subject: [PATCH] Some fixies --- CMakeLists.txt | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f275614..955a7f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.0) project(i3ipc++) +OPTION(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF) + SET(BUILD_STATIC_LIBS ON) SET(BUILD_SHARED_LIBS OFF) add_subdirectory(3rd/jsoncpp) @@ -29,22 +31,24 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") file(GLOB_RECURSE SRC src/*.cpp) add_library(i3ipc++_static STATIC ${SRC}) -SET(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR}) -SET(I3IPCpp_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/) -SET(I3IPCpp_LIBRARIES i3ipc++_static ${SIGCPP_LIBRARIES} jsoncpp_lib_static) +SET(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) +SET(I3IPCpp_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/ PARENT_SCOPE) +SET(I3IPCpp_LIBRARIES i3ipc++_static ${SIGCPP_LIBRARIES} jsoncpp_lib_static PARENT_SCOPE) -find_package(CxxTest) -if(CXXTEST_FOUND) - include_directories(${CXXTEST_INCLUDE_DIR}) - include_directories(src/) - add_definitions( - -DTEST_SRC_ROOT="${CMAKE_CURRENT_SOURCE_DIR}/test" - ) +if(I3IPCpp_WITH_TESTS) + find_package(CxxTest) + if(CXXTEST_FOUND) + include_directories(${CXXTEST_INCLUDE_DIR}) + include_directories(src/) + add_definitions( + -DTEST_SRC_ROOT="${CMAKE_CURRENT_SOURCE_DIR}/test" + ) - enable_testing() - file(GLOB SRC_TEST test/*.hpp) - CXXTEST_ADD_TEST(i3ipcpp_check test.cpp ${SRC_TEST}) - target_link_libraries(i3ipcpp_check ${I3IPCpp_LIBRARIES}) -else() - message(WARNING "CxxTest not found. Unable to run unit-tests") + enable_testing() + file(GLOB SRC_TEST test/*.hpp) + CXXTEST_ADD_TEST(i3ipcpp_check test.cpp ${SRC_TEST}) + target_link_libraries(i3ipcpp_check ${I3IPCpp_LIBRARIES}) + else() + message(WARNING "CxxTest not found. Unable to run unit-tests") + endif() endif()