Guard testing code to avoid problems when including using FetchContent.MakeAvailable

This commit is contained in:
Alex Selimov 2025-04-16 07:55:10 -04:00
parent 6775d995d7
commit 85bbc2e1dd

View File

@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.9)
set(NAME "Vec3") set(NAME "Vec3")
project(${NAME}) project(${NAME})
enable_testing()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_options(-Wall -Wextra -Wpedantic) add_compile_options(-Wall -Wextra -Wpedantic)
@ -11,6 +10,9 @@ set(CMAKE_CXX_STANDARD 17)
include_directories(include) include_directories(include)
add_subdirectory(include) add_subdirectory(include)
if (PROJECT_IS_TOP_LEVEL)
enable_testing()
add_subdirectory(tests) add_subdirectory(tests)
# Doxygen Build # Doxygen Build
@ -36,3 +38,4 @@ if(DOXYGEN_FOUND)
else(DOXYGEN_FOUND) else(DOXYGEN_FOUND)
message("Doxygen needs to be installed to generate the documentation.") message("Doxygen needs to be installed to generate the documentation.")
endif(DOXYGEN_FOUND) endif(DOXYGEN_FOUND)
endif()