From 4ae9513ff9182b9c519504a73435ed575a821300 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Tue, 30 Aug 2022 10:42:35 -0600 Subject: [PATCH] Dont enable tests if building standalone Previously, tests would always be enabled if the repo was the top level project, which isn't desireable for users. This alters the logic to, by default, only enabling tests when its a top level project, but still allowing users to *not* enable tests by setting VK_BOOTSTRAP_TEST to off. --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1e0181..4d87f43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,10 +81,15 @@ install(TARGETS vk-bootstrap vk-bootstrap-compiler-warnings vk-bootstrap-vulkan- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" OFF) - -if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR VK_BOOTSTRAP_TEST) +# By default, we want to only build tests if this repo is built standalone, but still should be configurable by the user +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + set(VK_BOOTSTRAP_TEST_DEFAULT_VALUE ON) +else() + set(VK_BOOTSTRAP_TEST_DEFAULT_VALUE OFF) +endif() +option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" ${VK_BOOTSTRAP_TEST_DEFAULT_VALUE}) +if(VK_BOOTSTRAP_TEST) add_subdirectory(ext) add_subdirectory(tests) add_subdirectory(example)