diff options
Diffstat (limited to 'third_party/vulkan-deps/glslang/src/CMakeLists.txt')
-rw-r--r-- | third_party/vulkan-deps/glslang/src/CMakeLists.txt | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/third_party/vulkan-deps/glslang/src/CMakeLists.txt b/third_party/vulkan-deps/glslang/src/CMakeLists.txt index e0802af80a..5cdd3e31ab 100644 --- a/third_party/vulkan-deps/glslang/src/CMakeLists.txt +++ b/third_party/vulkan-deps/glslang/src/CMakeLists.txt @@ -33,6 +33,11 @@ cmake_minimum_required(VERSION 3.17.2) project(glslang) +if (CMAKE_VERSION VERSION_LESS "3.21") + # https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html + string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PROJECT_IS_TOP_LEVEL) +endif() + set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Adhere to GNU filesystem layout conventions @@ -70,16 +75,9 @@ endif() # Furthermore testing is equally problematic. if (IOS OR ANDROID) set(ENABLE_GLSLANG_BINARIES OFF) - - set(ENABLE_CTEST OFF) - set(BUILD_TESTING OFF) + set(GLSLANG_TESTS OFF) endif() -option(SKIP_GLSLANG_INSTALL "Skip installation") - -if(NOT ${SKIP_GLSLANG_INSTALL}) - set(ENABLE_GLSLANG_INSTALL ON) -endif() option(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" ON) option(ENABLE_GLSLANG_BINARIES "Builds glslang and spirv-remap" ON) @@ -107,11 +105,6 @@ if(MINGW OR (APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")) endif() option(ENABLE_PCH "Enables Precompiled header" ON) -option(ENABLE_CTEST "Enables testing" ON) - -if(ENABLE_CTEST) - include(CTest) -endif() if(ENABLE_HLSL) add_compile_definitions(ENABLE_HLSL) @@ -306,34 +299,39 @@ if(ENABLE_GLSLANG_BINARIES) add_subdirectory(StandAlone) endif() add_subdirectory(SPIRV) -if(ENABLE_CTEST) - add_subdirectory(gtests) -endif() -if(ENABLE_CTEST AND BUILD_TESTING) - # glslang-testsuite runs a bash script on Windows. - # Make sure to use '-o igncr' flag to ignore carriage returns (\r). - set(IGNORE_CR_FLAG "") - if(WIN32) - set(IGNORE_CR_FLAG -o igncr) - endif() +# Testing / installation only makes sense when the project is top level. +# +# Otherwise add_subdirectory users have a harder time consuming the library. +# Since glslang will pollute the installation and add undesirable testing. +if(PROJECT_IS_TOP_LEVEL) + option(GLSLANG_TESTS "Enable glslang testing") + if(GLSLANG_TESTS) + enable_testing() + add_subdirectory(gtests) + + # glslang-testsuite runs a bash script on Windows. + # Make sure to use '-o igncr' flag to ignore carriage returns (\r). + set(IGNORE_CR_FLAG "") + if(WIN32) + set(IGNORE_CR_FLAG -o igncr) + endif() - if (CMAKE_CONFIGURATION_TYPES) - set(RESULTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/localResults) - set(VALIDATOR_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/$<CONFIG>/glslang) - set(REMAP_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/$<CONFIG>/spirv-remap) - else() - set(RESULTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/localResults) - set(VALIDATOR_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/glslang) - set(REMAP_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/spirv-remap) - endif() + if (CMAKE_CONFIGURATION_TYPES) + set(RESULTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/localResults) + set(VALIDATOR_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/$<CONFIG>/glslang) + set(REMAP_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/$<CONFIG>/spirv-remap) + else() + set(RESULTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/localResults) + set(VALIDATOR_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/glslang) + set(REMAP_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/spirv-remap) + endif() - add_test(NAME glslang-testsuite - COMMAND bash ${IGNORE_CR_FLAG} runtests ${RESULTS_PATH} ${VALIDATOR_PATH} ${REMAP_PATH} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Test/) -endif() + add_test(NAME glslang-testsuite + COMMAND bash ${IGNORE_CR_FLAG} runtests ${RESULTS_PATH} ${VALIDATOR_PATH} ${REMAP_PATH} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Test/) + endif() -if(ENABLE_GLSLANG_INSTALL) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake.in" [=[ @PACKAGE_INIT@ @INSTALL_CONFIG_UNIX@ |