diff --git a/hueplusplus/test/CMakeLists.txt b/hueplusplus/test/CMakeLists.txt new file mode 100755 index 0000000..81143aa --- /dev/null +++ b/hueplusplus/test/CMakeLists.txt @@ -0,0 +1,41 @@ +# Download and unpack googletest at configure time +configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) +execute_process(COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} . + RESULT_VARIABLE result +WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/hueplusplus/test/googletest-download" ) +if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") +endif() +execute_process(COMMAND "${CMAKE_COMMAND}" --build . + RESULT_VARIABLE result +WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/hueplusplus/test/googletest-download" ) +if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") +endif() + +# Prevent overriding the parent project's compiler/linker +# settings on Windows +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +# Add googletest directly to our build. This defines +# the gtest and gtest_main targets. +add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src + ${CMAKE_BINARY_DIR}/googletest-build) + +# The gtest/gtest_main targets carry header search path +# dependencies automatically when using CMake 2.8.11 or +# later. Otherwise we have to add them here ourselves. +if (CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories("${gtest_SOURCE_DIR}/include") +endif() + +file(GLOB TEST_SOURCES test_*) + +add_executable(HuePlusPlus_Test ${TEST_SOURCES} ${hueplusplus_SOURCES}) +target_link_libraries(HuePlusPlus_Test gtest gmock) +# prevent Main.cpp from defining main() +target_compile_definitions(HuePlusPlus_Test PUBLIC MAIN_CPP_NO_MAIN_FUNCTION) +target_include_directories(HuePlusPlus_Test PUBLIC ${GTest_INCLUDE_DIRS}) +target_include_directories(HuePlusPlus_Test PUBLIC ${HuePlusPlus_INCLUDE_DIR}) +set_property(TARGET HuePlusPlus_Test PROPERTY CXX_STANDARD 14) +set_property(TARGET HuePlusPlus_Test PROPERTY CXX_EXTENSIONS OFF) diff --git a/hueplusplus/test/CMakeLists.txt.in b/hueplusplus/test/CMakeLists.txt.in new file mode 100755 index 0000000..257b755 --- /dev/null +++ b/hueplusplus/test/CMakeLists.txt.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8.2) + +project(googletest-download NONE) + +include(ExternalProject) +ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG master + SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +)