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:
David Neto 2024-02-12 21:53:15 +00:00 committed by arcady-lunarg
parent 47a02a987c
commit b4a6efcda2
6 changed files with 62 additions and 49 deletions

View file

@ -87,19 +87,19 @@ if(WIN32)
source_group("Source" FILES ${SOURCES})
endif()
if(PROJECT_IS_TOP_LEVEL)
install(TARGETS glslang-standalone EXPORT glslang-targets)
# Create a symbolic link to glslang named glslangValidator for backwards compatibility
set(legacy_glslang_name "glslangValidator${CMAKE_EXECUTABLE_SUFFIX}")
set(link_method create_symlink)
if (WIN32 OR MINGW)
set(link_method copy_if_different)
endif()
add_custom_command(TARGET glslang-standalone
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E ${link_method} $<TARGET_FILE_NAME:glslang-standalone> ${legacy_glslang_name}
WORKING_DIRECTORY $<TARGET_FILE_DIR:glslang-standalone>)
# Create a symbolic link to glslang named glslangValidator for backwards compatibility
set(legacy_glslang_name "glslangValidator${CMAKE_EXECUTABLE_SUFFIX}")
set(link_method create_symlink)
if (WIN32 OR MINGW)
set(link_method copy_if_different)
endif()
add_custom_command(TARGET glslang-standalone
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E ${link_method} $<TARGET_FILE_NAME:glslang-standalone> ${legacy_glslang_name}
WORKING_DIRECTORY $<TARGET_FILE_DIR:glslang-standalone>)
if(GLSLANG_ENABLE_INSTALL)
install(TARGETS glslang-standalone EXPORT glslang-targets)
# Create the same symlink at install time
install(CODE "execute_process( \
@ -109,5 +109,4 @@ if(PROJECT_IS_TOP_LEVEL)
if(ENABLE_SPVREMAPPER)
install(TARGETS spirv-remap EXPORT glslang-targets)
endif()
endif()
endif(GLSLANG_ENABLE_INSTALL)