cmake_minimum_required(VERSION 2.8) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test) # use pkg-config to fix building on debian unstable find_package(PkgConfig REQUIRED) pkg_check_modules(JSONCPP REQUIRED jsoncpp) find_package(Threads REQUIRED) find_package(Boost 1.67 REQUIRED COMPONENTS system) # Setup testing enable_testing() pkg_check_modules(GMOCK REQUIRED gmock) find_package(GTest REQUIRED) include_directories(${Boost_INCLUDE_DIR} ${JSONCPP_INCLUDEDIR} ${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}) # Add test cpp file add_executable(jsonCommanderTest test/JsonCommanderTest.cpp src/JsonCommander.cpp src/FileManager.cpp src/base64.cpp src/UserManager.cpp src/Config.cpp) target_link_libraries(jsonCommanderTest ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${JSONCPP_LIBRARIES} ${GMOCK_LIBRARIES} ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY}) add_test( NAME jsonCommanderTest COMMAND jsonCommanderTest )