From 99afe23513054db4add5143de4aa3a826e8c6c75 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Thu, 10 Dec 2015 23:08:23 +0000 Subject: [PATCH] Tests: Add tests for FindGTest --- Tests/CMakeLists.txt | 5 +++++ Tests/FindGTest/CMakeLists.txt | 10 ++++++++++ Tests/FindGTest/Test/CMakeLists.txt | 17 +++++++++++++++++ Tests/FindGTest/Test/main.cxx | 6 ++++++ 4 files changed, 38 insertions(+) create mode 100644 Tests/FindGTest/CMakeLists.txt create mode 100644 Tests/FindGTest/Test/CMakeLists.txt create mode 100644 Tests/FindGTest/Test/main.cxx diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5d492cfa5..65bfb77d7 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1362,6 +1362,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(CMake_TEST_FindGSL) add_subdirectory(FindGSL) endif() + + if(CMake_TEST_FindGTest) + add_subdirectory(FindGTest) + endif() + if(CMake_TEST_FindJsonCpp) add_subdirectory(FindJsonCpp) endif() diff --git a/Tests/FindGTest/CMakeLists.txt b/Tests/FindGTest/CMakeLists.txt new file mode 100644 index 000000000..cbc92b144 --- /dev/null +++ b/Tests/FindGTest/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindGTest.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindGTest/Test" + "${CMake_BINARY_DIR}/Tests/FindGTest/Test" + ${build_generator_args} + --build-project TestFindGTest + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) diff --git a/Tests/FindGTest/Test/CMakeLists.txt b/Tests/FindGTest/Test/CMakeLists.txt new file mode 100644 index 000000000..99368ac71 --- /dev/null +++ b/Tests/FindGTest/Test/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindGTest CXX) +include(CTest) + +# CMake does not actually provide FindGTest publicly. +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/Modules) + +find_package(GTest REQUIRED) + +add_executable(test_gtest_tgt main.cxx) +target_link_libraries(test_gtest_tgt GTest::Main) +add_test(NAME test_gtest_tgt COMMAND test_gtest_tgt) + +add_executable(test_gtest_var main.cxx) +target_include_directories(test_gtest_var PRIVATE ${GTEST_INCLUDE_DIRS}) +target_link_libraries(test_gtest_var PRIVATE ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +add_test(NAME test_gtest_var COMMAND test_gtest_var) diff --git a/Tests/FindGTest/Test/main.cxx b/Tests/FindGTest/Test/main.cxx new file mode 100644 index 000000000..0572a5ddc --- /dev/null +++ b/Tests/FindGTest/Test/main.cxx @@ -0,0 +1,6 @@ +#include + +TEST(FindCMake, LinksAndRuns) +{ + ASSERT_TRUE(true); +}