cmake: Do not install static libraries in shared build mode.
authorRalf Habacker <ralf.habacker@freenet.de>
Mon, 12 Sep 2022 08:18:51 +0000 (10:18 +0200)
committerRalf Habacker <ralf.habacker@freenet.de>
Tue, 13 Sep 2022 13:57:44 +0000 (15:57 +0200)
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
glslang/CMakeLists.txt
glslang/OSDependent/Unix/CMakeLists.txt

index 841b3e2..b44cbc7 100644 (file)
@@ -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()
index f63e8fc..72e82b4 100644 (file)
@@ -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}
index ec1eda4..16eb939 100644 (file)
@@ -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