From 7cd519511c32d7e86d901c7ed231cb84c652d18d Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 12 Sep 2022 10:18:51 +0200 Subject: [PATCH] cmake: Do not install static libraries in shared build mode. The glslang cmake build system installs static libraries in addition to the dynamic glslang library, which are required when used in a package that uses glslang when calling find_package(). Distributions such as openSUSE (and perhaps others) use a "shared only" strategy, which conflicts with the current state of the glslang build system. The static libraries mentioned are already all included in glslang and thus not needed. With this commit, these will no longer install the associated cmake support files when glslang is built shared. --- OGLCompilersDLL/CMakeLists.txt | 4 ++-- glslang/CMakeLists.txt | 42 +++++++++++++++++---------------- glslang/OSDependent/Unix/CMakeLists.txt | 2 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/OGLCompilersDLL/CMakeLists.txt b/OGLCompilersDLL/CMakeLists.txt index 841b3e2..b44cbc7 100644 --- a/OGLCompilersDLL/CMakeLists.txt +++ b/OGLCompilersDLL/CMakeLists.txt @@ -41,7 +41,7 @@ if(WIN32) source_group("Source" FILES ${SOURCES}) endif(WIN32) -if(ENABLE_GLSLANG_INSTALL) +if(ENABLE_GLSLANG_INSTALL AND NOT BUILD_SHARED_LIBS) install(TARGETS OGLCompiler EXPORT glslang-targets) # Backward compatibility @@ -56,4 +56,4 @@ if(ENABLE_GLSLANG_INSTALL) ") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/OGLCompilerTargets.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) -endif(ENABLE_GLSLANG_INSTALL) +endif() diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt index f63e8fc..72e82b4 100644 --- a/glslang/CMakeLists.txt +++ b/glslang/CMakeLists.txt @@ -201,26 +201,28 @@ endif() ################################################################################ if(ENABLE_GLSLANG_INSTALL) install(TARGETS glslang EXPORT glslang-targets) - install(TARGETS MachineIndependent EXPORT glslang-targets) - install(TARGETS GenericCodeGen EXPORT glslang-targets) - - # Backward compatibility - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/glslangTargets.cmake" " - message(WARNING \"Using `glslangTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.\") - - if (NOT TARGET glslang::glslang) - include(\"\${CMAKE_CURRENT_LIST_DIR}/../../${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/glslang-targets.cmake\") - endif() - - if(${BUILD_SHARED_LIBS}) - add_library(glslang ALIAS glslang::glslang) - else() - add_library(glslang ALIAS glslang::glslang) - add_library(MachineIndependent ALIAS glslang::MachineIndependent) - add_library(GenericCodeGen ALIAS glslang::GenericCodeGen) - endif() - ") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glslangTargets.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) + if(NOT BUILD_SHARED_LIBS) + install(TARGETS MachineIndependent EXPORT glslang-targets) + install(TARGETS GenericCodeGen EXPORT glslang-targets) + + # Backward compatibility + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/glslangTargets.cmake" " + message(WARNING \"Using `glslangTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.\") + + if (NOT TARGET glslang::glslang) + include(\"\${CMAKE_CURRENT_LIST_DIR}/../../${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/glslang-targets.cmake\") + endif() + + if(${BUILD_SHARED_LIBS}) + add_library(glslang ALIAS glslang::glslang) + else() + add_library(glslang ALIAS glslang::glslang) + add_library(MachineIndependent ALIAS glslang::MachineIndependent) + add_library(GenericCodeGen ALIAS glslang::GenericCodeGen) + endif() + ") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glslangTargets.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) + endif() set(ALL_HEADERS ${GLSLANG_HEADERS} diff --git a/glslang/OSDependent/Unix/CMakeLists.txt b/glslang/OSDependent/Unix/CMakeLists.txt index ec1eda4..16eb939 100644 --- a/glslang/OSDependent/Unix/CMakeLists.txt +++ b/glslang/OSDependent/Unix/CMakeLists.txt @@ -52,7 +52,7 @@ else() target_link_libraries(OSDependent Threads::Threads) endif() -if(ENABLE_GLSLANG_INSTALL) +if(ENABLE_GLSLANG_INSTALL AND NOT BUILD_SHARED_LIBS) install(TARGETS OSDependent EXPORT glslang-targets) # Backward compatibility -- 2.7.4