Allow external control of whether Glslang will be tested or installed
Expose GLSLANG__TESTS and GLSLANG_ENABLE_INSTALL as options that can be controlled from an enclosing project, or from the command line. They retain the prior default behaviour. In particular, if Glslang is not the top level project, then they default to OFF. Fixes: #3507
This commit is contained in:
parent
47a02a987c
commit
b4a6efcda2
6 changed files with 62 additions and 49 deletions
|
|
@ -38,6 +38,9 @@ if (CMAKE_VERSION VERSION_LESS "3.21")
|
|||
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PROJECT_IS_TOP_LEVEL)
|
||||
endif()
|
||||
|
||||
set(GLSLANG_TESTS_DEFAULT ON) # Can be turned off, below, based on environment.
|
||||
set(GLSLANG_ENABLE_INSTALL_DEFAULT ON) # Can be turned off, below, based on environment.
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
# Adhere to GNU filesystem layout conventions
|
||||
|
|
@ -75,9 +78,25 @@ endif()
|
|||
# Furthermore testing is equally problematic.
|
||||
if (IOS OR ANDROID)
|
||||
set(ENABLE_GLSLANG_BINARIES OFF)
|
||||
set(GLSLANG_TESTS OFF)
|
||||
set(GLSLANG_TESTS_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
# Simplify the default case of including this project.
|
||||
# Otherwise add_subdirectory users have a harder time consuming the library.
|
||||
# Since glslang will pollute the installation and add undesirable testing.
|
||||
if(NOT PROJECT_IS_TOP_LEVEL)
|
||||
set(GLSLANG_TESTS_DEFAULT OFF)
|
||||
set(GLSLANG_ENABLE_INSTALL_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
# Control whether Glslang self-tests are built and tested.
|
||||
# Always expose this as an option, so the defaults can be overridden.
|
||||
option(GLSLANG_TESTS "Enable glslang testing" ${GLSLANG_TESTS_DEFAULT})
|
||||
|
||||
# Control whether to install Glslang.
|
||||
# Always expose this as an option, so the defaults can be overridden.
|
||||
option(GLSLANG_ENABLE_INSTALL "Enable glslang installation" ${GLSLANG_ENABLE_INSTALL_DEFAULT})
|
||||
|
||||
option(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" ON)
|
||||
|
||||
option(ENABLE_GLSLANG_BINARIES "Builds glslang and spirv-remap" ON)
|
||||
|
|
@ -300,38 +319,33 @@ if(ENABLE_GLSLANG_BINARIES)
|
|||
endif()
|
||||
add_subdirectory(SPIRV)
|
||||
|
||||
# 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)
|
||||
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()
|
||||
|
||||
add_test(NAME glslang-testsuite
|
||||
COMMAND bash ${IGNORE_CR_FLAG} runtests ${RESULTS_PATH} ${VALIDATOR_PATH} ${REMAP_PATH}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Test/)
|
||||
# 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()
|
||||
|
||||
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(GLSLANG_TESTS)
|
||||
|
||||
if (GLSLANG_ENABLE_INSTALL)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake.in" [=[
|
||||
@PACKAGE_INIT@
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
|
@ -375,4 +389,4 @@ if(PROJECT_IS_TOP_LEVEL)
|
|||
DESTINATION
|
||||
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
)
|
||||
endif()
|
||||
endif(GLSLANG_ENABLE_INSTALL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue