76 lines
1.7 KiB
CMake
76 lines
1.7 KiB
CMake
# Tests CMakeLists.txt
|
|
include(FetchContent)
|
|
|
|
# Download and configure Google Test
|
|
FetchContent_Declare(
|
|
googletest
|
|
URL https://github.com/google/googletest/archive/v1.14.0.zip
|
|
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
|
)
|
|
|
|
# Prevent overriding the parent project's compiler/linker on Windows
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
|
|
# Make Google Test available
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
# Include Google Test modules
|
|
include(GoogleTest)
|
|
|
|
# Create test executable for unit tests
|
|
add_executable(unit_tests
|
|
unit/main.cpp
|
|
)
|
|
|
|
# Link with Google Test and our library
|
|
target_link_libraries(unit_tests
|
|
PRIVATE
|
|
GTest::gtest_main
|
|
GTest::gmock_main
|
|
PokemonSim::pokemon_battle_sim
|
|
)
|
|
|
|
# Set up test discovery
|
|
gtest_discover_tests(unit_tests
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
PROPERTIES
|
|
LABELS "unit"
|
|
)
|
|
|
|
# Create test executable for integration tests
|
|
add_executable(integration_tests
|
|
integration/main.cpp
|
|
)
|
|
|
|
# Link with Google Test and our library
|
|
target_link_libraries(integration_tests
|
|
PRIVATE
|
|
GTest::gtest_main
|
|
GTest::gmock_main
|
|
PokemonSim::pokemon_battle_sim
|
|
)
|
|
|
|
# Set up test discovery
|
|
gtest_discover_tests(integration_tests
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
PROPERTIES
|
|
LABELS "integration"
|
|
)
|
|
|
|
# Include directories for tests
|
|
target_include_directories(unit_tests
|
|
PRIVATE
|
|
${CMAKE_SOURCE_DIR}/include
|
|
${CMAKE_SOURCE_DIR}/src
|
|
)
|
|
|
|
target_include_directories(integration_tests
|
|
PRIVATE
|
|
${CMAKE_SOURCE_DIR}/include
|
|
${CMAKE_SOURCE_DIR}/src
|
|
)
|
|
|
|
# Add test subdirectories
|
|
add_subdirectory(unit)
|
|
add_subdirectory(integration)
|