Revert "Experiment removing gsl_tests_config"

This reverts commit d02b9b664ae070f64b152f622a81471b93b2f5ed.
This commit is contained in:
Dmitry Kobets 2021-11-30 12:43:33 -08:00
parent d02b9b664a
commit 1cae46b563
2 changed files with 27 additions and 22 deletions

View File

@ -15,6 +15,7 @@ endif()
pkg_search_module(GTestMain gtest_main)
if (NOT GTestMain_FOUND)
message(INFO, "Manually building googletest")
# No pre-installed GTest is available, try to download it using Git.
find_package(Git REQUIRED QUIET)
@ -45,6 +46,7 @@ if (NOT GTestMain_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL
)
message(INFO, "Done: Manually building googletest")
endif()
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
@ -58,30 +60,11 @@ if (MSVC AND (GSL_CXX_STANDARD EQUAL 17))
set(GSL_CPLUSPLUS_OPT -Zc:__cplusplus -permissive-)
endif()
add_executable(gsl_tests
algorithm_tests.cpp
assertion_tests.cpp
at_tests.cpp
byte_tests.cpp
notnull_tests.cpp
owner_tests.cpp
span_compatibility_tests.cpp
span_ext_tests.cpp
span_tests.cpp
strict_notnull_tests.cpp
string_span_tests.cpp
utils_tests.cpp
)
# for tests to find the gtest header
target_include_directories(gsl_tests SYSTEM INTERFACE
googletest/googletest/include
)
# this interface adds compile options to how the tests are run
# please try to keep entries ordered =)
add_library(gsl_tests_config INTERFACE)
if(MSVC) # MSVC or simulating MSVC
target_compile_options(gsl_tests PRIVATE
target_compile_options(gsl_tests_config INTERFACE
${GSL_CPLUSPLUS_OPT}
/EHsc
/W4
@ -121,7 +104,7 @@ if(MSVC) # MSVC or simulating MSVC
>
)
else()
target_compile_options(gsl_tests PRIVATE
target_compile_options(gsl_tests_config INTERFACE
-fno-strict-aliasing
-Wall
-Wcast-align
@ -181,8 +164,29 @@ else()
)
endif(MSVC)
# for tests to find the gtest header
target_include_directories(gsl_tests_config SYSTEM INTERFACE
googletest/googletest/include
)
add_executable(gsl_tests
algorithm_tests.cpp
assertion_tests.cpp
at_tests.cpp
byte_tests.cpp
notnull_tests.cpp
owner_tests.cpp
span_compatibility_tests.cpp
span_ext_tests.cpp
span_tests.cpp
strict_notnull_tests.cpp
string_span_tests.cpp
utils_tests.cpp
)
target_link_libraries(gsl_tests
Microsoft.GSL::GSL
gsl_tests_config
${GTestMain_LIBRARIES}
)
add_test(gsl_tests gsl_tests)

View File

@ -11,4 +11,5 @@ ExternalProject_Add(googletest
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
CMAKE_ARGS -Wno-dev
)