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

Add glslangConfig.cmake or glslang-config.cmake file to facilitate cmake package interaction #2570

Closed axsaucedo closed 11 months ago

axsaucedo commented 3 years ago

Currently when glslang is installed, any import using find_package(glslang REQUIRED) will fail given that there is no glslangConfig.cmake or glslang-config.cmake made available as part of the install.

This can be fixed by adding an extra file under the names above, with contents along the lines of:

# inside file glslangConfig.cmake

include("${CMAKE_CURRENT_LIST_DIR}/OSDependentTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/OGLCompilerTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/glslangTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/SPIRVTargets.cmake")

Edit: The VCPKG project seems to have a glslangConfig.cmake file that could be used as a base

axsaucedo commented 3 years ago

Thank you @aliPMPAINT but thats still a workaround to a Findglslang.cmake / glslanConfig.cmake file - it would still be ideal to just add the compatibility with find_package as it's a standard workflow for cmake projects

greg-lunarg commented 3 years ago

I am currently not funded to make this improvement but if someone is knowledgeable and wants to see this happen sooner than later, I will accept a PR. Let me know if you start work and I will assign.

axsaucedo commented 3 years ago

@greg-lunarg great to hear this is relevant. Not sure what you mean tho, what do you mean by funded? Is there a pay-to-fix structure, or is there a Forum where feature requests are upvoted? Not really familiar with what's the process for KhronosGroup repos for new features like this one, is there a README/Forum where I can find out more about this process?

greg-lunarg commented 3 years ago

This repo is open source controlled by KhronosGroup. All the development is "donated" by individuals or companies interested in seeing this software be useful.

As such, my consulting company is funded by a well-known ISV to maintain this repo. Right now my level of funding is just enough to triage new bugs, fix bugs I can't find anyone else to fix and review and merge bug fixes and new features presented by others.

If you wish to submit a PR, you only need to submit a Contributing License Agreement (CLA).

axsaucedo commented 3 years ago

Thank you for the detail @greg-lunarg , this is quite informative! Ok great, I didn't know this structure, but makes complete sense, and I can see how fixing bugs is something that would take precedence over adding features.

I also didn't know about the CLA, I would be interested to give this a go and add this contribution - what is the process I would go through in order to set up the CLA?

greg-lunarg commented 3 years ago

I am not sure how to set up the CLA ahead-of-time, but when you attempt to create your first PR you will be guided through the CLA process.

Good luck and thanks in advance for your contributions!

robertosfield commented 3 years ago

Has the been progress on creation of glslangConfig.cmake? I am currently revisiting how the VulkanSceneGraph project pulls in the optional glslang dependency, the lack of glslangConfig.cmake previously led me to hack a vsg_glslangConfig.cmake in absence of any official support and for backwards compatibility. I'd much rather rely on an official glslangConfig.cmake though.

The vsg_glslangConfig.cmake I created is:

vsg_glslangConfig.cmake

I'm not proposing this particular script for the glsLang project, @axsaucedo suggestion relying upon glslangTargets.cmake etc is better for when these are available.

If there is a PR that adds glslangConfig.cmake I'd be happy to help out with testing.

hiradyazdan commented 3 years ago

The same issue applies to shaderc, but its vcpkg port doesn't have cmake config to make it available. This issue might be related https://github.com/microsoft/vcpkg/issues/16658

magicse commented 2 years ago

Mingw64 CodeBlocks Windows 7 I added "find_package(glslang)" in to my general CMakeLists.txt But the The same problem.

CMake Warning at Z:/AI_SDK/CPP_GFPGAN/Real-ESRGAN-ncnn-vulkan/vulkan/glslang-master-tot/Build/install/lib/cmake/OSDependentTargets.cmake:2 (message):
  Using `OSDependentTargets.cmake` is deprecated: use `find_package(glslang)`
  to find glslang CMake targets.
Call Stack (most recent call first):
  CMakeLists.txt:115 (include)

CMake Warning at Z:/AI_SDK/CPP_GFPGAN/Real-ESRGAN-ncnn-vulkan/vulkan/glslang-master-tot/Build/install/lib/cmake/OGLCompilerTargets.cmake:2 (message):
  Using `OGLCompilerTargets.cmake` is deprecated: use `find_package(glslang)`
  to find glslang CMake targets.
Call Stack (most recent call first):
  CMakeLists.txt:116 (include)

CMake Warning at Z:/AI_SDK/CPP_GFPGAN/Real-ESRGAN-ncnn-vulkan/vulkan/glslang-master-tot/Build/install/lib/cmake/HLSLTargets.cmake:2 (message):
  Using `HLSLTargets.cmake` is deprecated: use `find_package(glslang)` to
  find glslang CMake targets.
Call Stack (most recent call first):
  CMakeLists.txt:119 (include)

CMake Warning at Z:/AI_SDK/CPP_GFPGAN/Real-ESRGAN-ncnn-vulkan/vulkan/glslang-master-tot/Build/install/lib/cmake/glslangTargets.cmake:2 (message):
  Using `glslangTargets.cmake` is deprecated: use `find_package(glslang)` to
  find glslang CMake targets.
Call Stack (most recent call first):
  CMakeLists.txt:121 (include)

CMake Warning at Z:/AI_SDK/CPP_GFPGAN/Real-ESRGAN-ncnn-vulkan/vulkan/glslang-master-tot/Build/install/lib/cmake/SPIRVTargets.cmake:2 (message):
  Using `SPIRVTargets.cmake` is deprecated: use `find_package(glslang)` to
  find glslang CMake targets.
Call Stack (most recent call first):
  CMakeLists.txt:122 (include)
juan-lunarg commented 11 months ago

The vulkan validation layers currently uses glslangConfig.cmake right now:

https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/9534456051ec513b731f22f56860368cef445a92/tests/CMakeLists.txt#L222

What support is missing exactly?

juan-lunarg commented 11 months ago

I think this issue can be closed as far as I can see. Although it would be good to add additional testing to ensure it doesn't accidentally break. But that's another PR.

@arcady-lunarg your thoughts?

arcady-lunarg commented 11 months ago

This was fixed by https://github.com/KhronosGroup/glslang/pull/2989, which should have been linked to this issue but was inadvertently not due to a typo.

axsaucedo commented 11 months ago

Thabk you for following up