Only install/test if PROJECT_IS_TOP_LEVEL
Further remove installing glslangtests. There isn't a need to do that. glslangtests isn't a deliverable.
This commit is contained in:
parent
3b99124593
commit
cf1fbbff44
7 changed files with 39 additions and 51 deletions
|
|
@ -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
|
||||
|
|
@ -73,13 +78,6 @@ if (IOS OR ANDROID)
|
|||
set(GLSLANG_TESTS OFF)
|
||||
endif()
|
||||
|
||||
option(GLSLANG_TESTS "Enable glslang testing")
|
||||
|
||||
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)
|
||||
|
|
@ -302,6 +300,12 @@ 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)
|
||||
|
|
@ -328,7 +332,6 @@ if(GLSLANG_TESTS)
|
|||
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@
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ if(WIN32)
|
|||
source_group("Source" FILES ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
|
||||
endif()
|
||||
|
||||
if(ENABLE_GLSLANG_INSTALL)
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
if (ENABLE_SPVREMAPPER)
|
||||
install(TARGETS SPVRemapper EXPORT glslang-targets)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ if(WIN32)
|
|||
source_group("Source" FILES ${SOURCES})
|
||||
endif()
|
||||
|
||||
if(ENABLE_GLSLANG_INSTALL)
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
install(TARGETS glslang-standalone EXPORT glslang-targets)
|
||||
|
||||
# Backward compatibility
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ endif()
|
|||
################################################################################
|
||||
# install
|
||||
################################################################################
|
||||
if(ENABLE_GLSLANG_INSTALL)
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
install(TARGETS glslang EXPORT glslang-targets)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS MachineIndependent EXPORT glslang-targets)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(OSDependent Threads::Threads)
|
||||
|
||||
if(ENABLE_GLSLANG_INSTALL AND NOT BUILD_SHARED_LIBS)
|
||||
if(PROJECT_IS_TOP_LEVEL AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS OSDependent EXPORT glslang-targets)
|
||||
|
||||
# Backward compatibility
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ if(WIN32)
|
|||
source_group("Source" FILES ${SOURCES})
|
||||
endif()
|
||||
|
||||
if(ENABLE_GLSLANG_INSTALL)
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
install(TARGETS OSDependent EXPORT glslang-targets)
|
||||
|
||||
# Backward compatibility
|
||||
|
|
|
|||
|
|
@ -68,21 +68,6 @@ if(GLSLANG_TESTS)
|
|||
glslang_pch(glslangtests ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
|
||||
set_property(TARGET glslangtests PROPERTY FOLDER tests)
|
||||
glslang_set_link_args(glslangtests)
|
||||
if(ENABLE_GLSLANG_INSTALL)
|
||||
install(TARGETS glslangtests EXPORT glslang-targets)
|
||||
|
||||
# Backward compatibility
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/glslangtestsTargets.cmake" "
|
||||
message(WARNING \"Using `glslangtestsTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.\")
|
||||
|
||||
if (NOT TARGET glslang::glslangtests)
|
||||
include(\"${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${PROJECT_NAME}/glslang-targets.cmake\")
|
||||
endif()
|
||||
|
||||
add_library(glslangtests ALIAS glslang::glslangtests)
|
||||
")
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glslangtestsTargets.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
|
||||
endif()
|
||||
|
||||
set(GLSLANG_TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
|
||||
# Supply a default test root directory, so that manual testing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue