- Removed PARENT_SCOPE from various dependency target definitions in CMake files (grpc.cmake, imgui.cmake, sdl2.cmake, testing.cmake, yaml.cmake). - Ensured that all targets are set locally for better clarity and management. Benefits: - Simplifies the dependency management process and improves the readability of CMake configurations.
70 lines
1.7 KiB
CMake
70 lines
1.7 KiB
CMake
# Testing dependencies (GTest, Benchmark)
|
|
# Uses CPM.cmake for consistent cross-platform builds
|
|
|
|
if(NOT YAZE_BUILD_TESTS)
|
|
return()
|
|
endif()
|
|
|
|
include(cmake/CPM.cmake)
|
|
include(cmake/dependencies.lock)
|
|
|
|
message(STATUS "Setting up testing dependencies with CPM.cmake")
|
|
|
|
# Google Test (includes GMock)
|
|
CPMAddPackage(
|
|
NAME googletest
|
|
VERSION ${GTEST_VERSION}
|
|
GITHUB_REPOSITORY google/googletest
|
|
GIT_TAG v${GTEST_VERSION}
|
|
OPTIONS
|
|
"BUILD_GMOCK ON"
|
|
"INSTALL_GTEST OFF"
|
|
"gtest_force_shared_crt ON"
|
|
)
|
|
|
|
# Verify GTest and GMock targets are available
|
|
if(NOT TARGET gtest)
|
|
message(FATAL_ERROR "GTest target not found after CPM fetch")
|
|
endif()
|
|
|
|
if(NOT TARGET gmock)
|
|
message(FATAL_ERROR "GMock target not found after CPM fetch")
|
|
endif()
|
|
|
|
# Google Benchmark (optional, for performance tests)
|
|
if(YAZE_ENABLE_COVERAGE OR DEFINED ENV{YAZE_ENABLE_BENCHMARKS})
|
|
CPMAddPackage(
|
|
NAME benchmark
|
|
VERSION ${BENCHMARK_VERSION}
|
|
GITHUB_REPOSITORY google/benchmark
|
|
GIT_TAG v${BENCHMARK_VERSION}
|
|
OPTIONS
|
|
"BENCHMARK_ENABLE_TESTING OFF"
|
|
"BENCHMARK_ENABLE_INSTALL OFF"
|
|
)
|
|
|
|
if(NOT TARGET benchmark::benchmark)
|
|
message(FATAL_ERROR "Benchmark target not found after CPM fetch")
|
|
endif()
|
|
|
|
set(YAZE_BENCHMARK_TARGETS benchmark::benchmark)
|
|
endif()
|
|
|
|
# Create convenience targets for the rest of the project
|
|
add_library(yaze_testing INTERFACE)
|
|
target_link_libraries(yaze_testing INTERFACE
|
|
gtest
|
|
gtest_main
|
|
gmock
|
|
gmock_main
|
|
)
|
|
|
|
if(TARGET benchmark::benchmark)
|
|
target_link_libraries(yaze_testing INTERFACE benchmark::benchmark)
|
|
endif()
|
|
|
|
# Export testing targets for use in other CMake files
|
|
set(YAZE_TESTING_TARGETS yaze_testing)
|
|
|
|
message(STATUS "Testing dependencies setup complete - GTest + GMock available")
|