| cmake_minimum_required(VERSION 3.20) | |
| # Fetch GoogleTest | |
| include(FetchContent) | |
| FetchContent_Declare( | |
| googletest | |
| GIT_REPOSITORY https://github.com/google/googletest.git | |
| GIT_TAG v1.14.0 | |
| ) | |
| FetchContent_MakeAvailable(googletest) | |
| # Test executable | |
| file(GLOB TEST_SOURCES "*.cpp") | |
| add_executable(${PROJECT_NAME}_tests ${TEST_SOURCES}) | |
| target_link_libraries(${PROJECT_NAME}_tests ${PROJECT_NAME} GTest::gtest_main) | |
| # Enable CTest | |
| include(GoogleTest) | |
| gtest_discover_tests(${PROJECT_NAME}_tests) | |