Add option to build tests with external gtest, closes #130
This commit is contained in:
parent
b2bff57d81
commit
2499fa4a67
@ -168,6 +168,7 @@ option(CPPTRACE_SANITIZER_BUILD "" OFF)
|
|||||||
option(CPPTRACE_WERROR_BUILD "" OFF)
|
option(CPPTRACE_WERROR_BUILD "" OFF)
|
||||||
option(CPPTRACE_POSITION_INDEPENDENT_CODE "" ON)
|
option(CPPTRACE_POSITION_INDEPENDENT_CODE "" ON)
|
||||||
option(CPPTRACE_IS_GH_ACTIONS "" OFF)
|
option(CPPTRACE_IS_GH_ACTIONS "" OFF)
|
||||||
|
option(CPPTRACE_USE_EXTERNAL_GTEST "" OFF)
|
||||||
|
|
||||||
mark_as_advanced(
|
mark_as_advanced(
|
||||||
CPPTRACE_BACKTRACE_PATH
|
CPPTRACE_BACKTRACE_PATH
|
||||||
@ -179,4 +180,5 @@ mark_as_advanced(
|
|||||||
CPPTRACE_VCPKG
|
CPPTRACE_VCPKG
|
||||||
CPPTRACE_CONDA_LIBDWARF_WEIRDNESS
|
CPPTRACE_CONDA_LIBDWARF_WEIRDNESS
|
||||||
CPPTRACE_IS_GH_ACTIONS
|
CPPTRACE_IS_GH_ACTIONS
|
||||||
|
CPPTRACE_USE_EXTERNAL_GTEST
|
||||||
)
|
)
|
||||||
|
|||||||
@ -38,6 +38,9 @@ endif()
|
|||||||
|
|
||||||
# primarily a workaround for github actions issue https://github.com/actions/runner-images/issues/8659
|
# primarily a workaround for github actions issue https://github.com/actions/runner-images/issues/8659
|
||||||
if(NOT CPPTRACE_IS_GH_ACTIONS)
|
if(NOT CPPTRACE_IS_GH_ACTIONS)
|
||||||
|
if(CPPTRACE_USE_EXTERNAL_GTEST)
|
||||||
|
find_package(GTest)
|
||||||
|
else()
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
googletest
|
googletest
|
||||||
@ -47,6 +50,7 @@ if(NOT CPPTRACE_IS_GH_ACTIONS)
|
|||||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||||
FetchContent_MakeAvailable(googletest)
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(unittest unittest.cpp)
|
add_executable(unittest unittest.cpp)
|
||||||
target_compile_features(unittest PRIVATE cxx_std_20)
|
target_compile_features(unittest PRIVATE cxx_std_20)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user