Improve GTest configuration.

This commit is contained in:
2019-09-22 17:30:09 +02:00
parent 1f8e19c49b
commit 7219712be4

View File

@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.12)
project(aoc2019)
find_package(Boost REQUIRED COMPONENTS program_options filesystem)
find_package(GTest)
find_package(GTest REQUIRED)
add_library(AoCSolutions src/implementations.hpp src/implementations.cpp src/day01.cpp src/days.hpp)
target_compile_features(AoCSolutions PUBLIC cxx_std_17)
@@ -12,12 +12,11 @@ add_executable(runner src/runner.cpp)
target_compile_features(runner PUBLIC cxx_std_17)
target_link_libraries(runner AoCSolutions Boost::program_options)
add_executable(test_solutions tests/test_solutions.cpp)
target_compile_features(test_solutions PUBLIC cxx_std_17)
target_link_libraries(test_solutions AoCSolutions Boost::filesystem gtest gtest_main)
target_compile_definitions(test_solutions PRIVATE "TEST_SAMPLES_DIR=\"${CMAKE_SOURCE_DIR}/tests/samples\"")
target_include_directories(test_solutions PRIVATE "${CMAKE_SOURCE_DIR}/src")
add_executable(unit_tests tests/test_solutions.cpp)
target_compile_features(unit_tests PUBLIC cxx_std_17)
target_link_libraries(unit_tests AoCSolutions Boost::filesystem GTest::GTest GTest::Main)
target_compile_definitions(unit_tests PRIVATE "TEST_SAMPLES_DIR=\"${CMAKE_SOURCE_DIR}/tests/samples\"")
target_include_directories(unit_tests PRIVATE "${CMAKE_SOURCE_DIR}/src")
enable_testing()
include(GoogleTest)
gtest_discover_tests(test_solutions)
gtest_discover_tests(unit_tests)