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.
This commit is contained in:
Charles Giessen 2022-08-30 10:42:35 -06:00
parent be26f7d464
commit 4ae9513ff9

View File

@ -81,10 +81,15 @@ install(TARGETS vk-bootstrap vk-bootstrap-compiler-warnings vk-bootstrap-vulkan-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" OFF) # 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)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR VK_BOOTSTRAP_TEST) 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(ext)
add_subdirectory(tests) add_subdirectory(tests)
add_subdirectory(example) add_subdirectory(example)