KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
3.07k stars 840 forks source link

Incomplete cmake find_package support #2751

Closed rhabacker closed 1 year ago

rhabacker commented 3 years ago

According to https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html#libraries-providing-config-file-packages, libraries that want to support cmake find_package() in configuration mode must install a set of files as shown for the VulkanSceneGraph package.

/usr/lib64/cmake/vsg/vsgConfig.cmake
/usr/lib64/cmake/vsg/vsgConfigVersion.cmake
/usr/lib64/cmake/vsg/vsgTargets-relwithdebinfo.cmake
/usr/lib64/cmake/vsg/vsgTargets.cmake

Once these files are installed, the vsg library can be added as a dependency to a package with cmake support by using

find_package(vsg)

to a CMakeLists.txt file.

A look into the installed files of the glslang package (see for example at openSUSE

/usr/lib64/cmake/HLSLTargets-relwithdebinfo.cmake
/usr/lib64/cmake/HLSLTargets.cmake
/usr/lib64/cmake/OGLCompilerTargets-relwithdebinfo.cmake
/usr/lib64/cmake/OGLCompilerTargets.cmake
/usr/lib64/cmake/OSDependentTargets-relwithdebinfo.cmake
/usr/lib64/cmake/OSDependentTargets.cmake
/usr/lib64/cmake/SPIRVTargets-relwithdebinfo.cmake
/usr/lib64/cmake/SPIRVTargets.cmake
/usr/lib64/cmake/SPVRemapperTargets-relwithdebinfo.cmake
/usr/lib64/cmake/SPVRemapperTargets.cmake
/usr/lib64/cmake/glslang-default-resource-limitsTargets-relwithdebinfo.cmake
/usr/lib64/cmake/glslang-default-resource-limitsTargets.cmake
/usr/lib64/cmake/glslangTargets-relwithdebinfo.cmake
/usr/lib64/cmake/glslangTargets.cmake
/usr/lib64/cmake/glslangValidatorTargets-relwithdebinfo.cmake
/usr/lib64/cmake/glslangValidatorTargets.cmake
/usr/lib64/cmake/spirv-remapTargets-relwithdebinfo.cmake
/usr/lib64/cmake/spirv-remapTargets.cmake

shows that there are no *Config.cmake and *Version.cmake` files.

For example, trying to use the glslang package with

find_package(glslang) 

will not find this package. Similar happens with the other provided packages SPIRV, HLSL, etc.

This problem has been currently documented on https://github.com/vsg-dev/VulkanSceneGraph/issues/322#issuecomment-915160228.

greg-lunarg commented 3 years ago

I am open to this improvement but do not have the resources to address it in the near future. If someone wishes to create such a change, please leave a comment to avoid duplicate effort.

rhabacker commented 3 years ago

I'm preparing such a change and will open an mr when I'm sure, that is works a expected.

sl1pkn07 commented 3 years ago

when do that, please, can change this?

diff --git a/OGLCompilersDLL/CMakeLists.txt b/OGLCompilersDLL/CMakeLists.txt
index 0b007d45c..74c287b3d 100644
--- a/OGLCompilersDLL/CMakeLists.txt
+++ b/OGLCompilersDLL/CMakeLists.txt
@@ -44,5 +44,5 @@ endif()
 if(ENABLE_GLSLANG_INSTALL)
     install(TARGETS OGLCompiler EXPORT OGLCompilerTargets
             ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
-   install(EXPORT OGLCompilerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+   install(EXPORT OGLCompilerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
 endif(ENABLE_GLSLANG_INSTALL)
diff --git a/SPIRV/CMakeLists.txt b/SPIRV/CMakeLists.txt
index 39d69940c..a96455c92 100644
--- a/SPIRV/CMakeLists.txt
+++ b/SPIRV/CMakeLists.txt
@@ -132,12 +132,12 @@ if(ENABLE_GLSLANG_INSTALL)
     endif()

     if (ENABLE_SPVREMAPPER)
-        install(EXPORT SPVRemapperTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+        install(EXPORT SPVRemapperTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
     endif()
     configure_file(${CMAKE_CURRENT_SOURCE_DIR}/spirv.pc.in ${CMAKE_CURRENT_BINARY_DIR}/spirv.pc @ONLY)
     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/spirv.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

-    install(EXPORT SPIRVTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+    install(EXPORT SPIRVTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

     install(FILES ${HEADERS} ${SPVREMAP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/SPIRV/)
 endif()
diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt
index bff9ab617..67cd1d339 100644
@@ -90,12 +90,12 @@ endif()
 if(ENABLE_GLSLANG_INSTALL)
     install(TARGETS glslangValidator EXPORT glslangValidatorTargets
             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-    install(EXPORT glslangValidatorTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+    install(EXPORT glslangValidatorTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

     if(ENABLE_SPVREMAPPER)
         install(TARGETS spirv-remap EXPORT spirv-remapTargets
             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-        install(EXPORT spirv-remapTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+        install(EXPORT spirv-remapTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
     endif()

     if(BUILD_SHARED_LIBS)
@@ -107,5 +107,5 @@ if(ENABLE_GLSLANG_INSTALL)
         install(TARGETS glslang-default-resource-limits EXPORT glslang-default-resource-limitsTargets
                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
     endif()
-    install(EXPORT glslang-default-resource-limitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+    install(EXPORT glslang-default-resource-limitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
 endif()
diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt
index 57d70d45f..f4ed06937 100644
--- a/glslang/CMakeLists.txt
+++ b/glslang/CMakeLists.txt
@@ -212,7 +212,7 @@ if(ENABLE_GLSLANG_INSTALL)
                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
     endif()

-    install(EXPORT glslangTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+    install(EXPORT glslangTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

     configure_file(${CMAKE_CURRENT_SOURCE_DIR}/glslang.pc.in ${CMAKE_CURRENT_BINARY_DIR}/glslang.pc @ONLY)
     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/glslang.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
diff --git a/glslang/OSDependent/Unix/CMakeLists.txt b/glslang/OSDependent/Unix/CMakeLists.txt
index 354a3e977..6763649aa 100644
--- a/glslang/OSDependent/Unix/CMakeLists.txt
+++ b/glslang/OSDependent/Unix/CMakeLists.txt
@@ -55,5 +55,5 @@ endif()
 if(ENABLE_GLSLANG_INSTALL)
     install(TARGETS OSDependent EXPORT OSDependentTargets
             ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
-   install(EXPORT OSDependentTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+   install(EXPORT OSDependentTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
 endif()
diff --git a/glslang/OSDependent/Windows/CMakeLists.txt b/glslang/OSDependent/Windows/CMakeLists.txt
index 9cf1b7fba..c32e0b8e1 100644
--- a/glslang/OSDependent/Windows/CMakeLists.txt
+++ b/glslang/OSDependent/Windows/CMakeLists.txt
@@ -50,5 +50,5 @@ endif()
 if(ENABLE_GLSLANG_INSTALL)
     install(TARGETS OSDependent EXPORT OSDependentTargets
             ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
-   install(EXPORT OSDependentTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+   install(EXPORT OSDependentTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
 endif()
diff --git a/hlsl/CMakeLists.txt b/hlsl/CMakeLists.txt
index 62faa1957..3d9765d1b 100644
--- a/hlsl/CMakeLists.txt
+++ b/hlsl/CMakeLists.txt
@@ -55,5 +55,5 @@ if(ENABLE_GLSLANG_INSTALL)
         install(TARGETS HLSL EXPORT HLSLTargets
                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
     endif()
-   install(EXPORT HLSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+   install(EXPORT HLSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
 endif()

is for install the cmake files into subtirectory insteaf off plain /usr/libfoo/cmake, like do a tons of other projects

is a cmake valid path, so not broke things

greetings

rhabacker commented 3 years ago

is for install the cmake files into subtirectory

This is covered by pr #2778

sl1pkn07 commented 3 years ago

Thanks

ncesario-lunarg commented 1 year ago

@rhabacker Is this still an issue? find_package(glslang) seems to work for me as expected on linux (testing with cmake 3.26.4).

rhabacker commented 1 year ago

The mentioned pr #2989 fixed this issue.