-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unified glslang
CMake config collecting glslang-targets
targets
#2989
Add unified glslang
CMake config collecting glslang-targets
targets
#2989
Conversation
Last but not least, it is that the current CMake setup to install CMake targets does not work anymore with recent CMake version (e.g. 3.23) Here is a configure output I get when using CMake 3.23.0 on Windows with VS generator
|
e83b80a
to
950022a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally LGTM. I tried this out in the Vulkan-ValidationLayers repo without changing any cmake, and also tried using these newly added targets (ncesario-lunarg/Vulkan-ValidationLayers@63e14e4), and both the old and new methods worked fine.
FYI @lunarpapillo. I don't think this will have any effect on SDK packaging, but if the SDK uses the installation artifacts of glslang, we'll probably want to include these new *.cmake
files.
The last time I did this was a few years ago, and I was kind of hoping it would be more streamlined, but cmake is cmake :)
@theblackunknown are you saying that an error should be expected with the current cmake on cmake versions >= 3.23.0? If so, I'm not seeing that. |
That is exactly my hope with this PR :) |
Good to know ! I just randomly run into this while developing this PR, I can try again to understand the cause but given your test this is likely specific to my dev setup. EDIT Just to double-check, I experienced an error with the current repo |
Right, I'm using cmake 3.23.2 (Windows), and not getting any error when building glslang on ToT master. |
@theblackunknown Thanks for the code! |
"${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/glslang-config-version.cmake" | ||
DESTINATION | ||
"${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this installed to CMAKE_INSTALL_DATADIR
? glslang ships architecture-dependent libraries, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, write_basic_package_version_file()
produces an architecture-dependent output unless called with the ARCH_INDEPENDENT
option,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this installed to CMAKE_INSTALL_DATADIR? glslang ships architecture-dependent libraries, right?
Good remark, I used this path out of habit using vcpkg
a lot.
I know there are other paths but I do not have experience using them, do you have any suggestions written in cmake portable way ?
Also I am curious on which issues you ran into issues using this arch independent path ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write_basic_package_version_file() produces an architecture-dependent output unless called with the ARCH_INDEPENDENT option,
Kind of echoing the previous comment, I do not have experience on how to correctly write this in a portable cmake way, can you suggest a good alternative here ?
I know that there are platform dependent libraries in glslang, but as we compiled binaries I guess we will always ends up with arch dependent libraries isn't it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that on Linux and most Unix-like platforms, share/
(datadir) is used to store architecture-independent data, while lib/
(libdir) is used to store architecture-specific files like compiled libraries.
Given this conventions, some distributions like Debian extend this concept to improve co-installability of different architecture variants of the same library (Debian and Ubuntu call this MultiArch), to make things like cross-compilation way easier.
In our case, as glslang-config.cmake
is in share/
, the library would be considered architecture independent and would be used when cross compiling to any architecture, while in fact glslang-config.cmake
points to libraries only usable on the build machine's architecture, breaking the whole process.
Now, in practise I don't know if this is done by CMake, what I described above is what pkg-config does (if I recall correctly), but in any case installing arch-dependent stuff in share/
is always wrong and can lead to issues. Installing arch-independent stuff to lib/
is less severe, but that's not what we have here.
Hope I made this clear enough :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it suffice to use CMAKE_INSTALL_LIBDIR
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it would
Edit: I mean, not only that, but also all the related ones. I can submit a PR if you prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please submit a PR. I'll happily review it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #3009
As glslang ships architecture dependant files, the Config file should be installed to libdir, not datadir. See KhronosGroup#2989 (comment) for more details. Here's the diff between the install tree before and after this patch: $ diff <(tree install-datadir) <(tree install) 1c1 < install-datadir --- > install 74,99c74,98 < ├── lib < │ ├── cmake < │ │ ├── glslang-default-resource-limitsTargets.cmake < │ │ ├── glslangTargets.cmake < │ │ ├── glslangValidatorTargets.cmake < │ │ ├── HLSLTargets.cmake < │ │ ├── OGLCompilerTargets.cmake < │ │ ├── OSDependentTargets.cmake < │ │ ├── spirv-remapTargets.cmake < │ │ ├── SPIRVTargets.cmake < │ │ └── SPVRemapperTargets.cmake < │ ├── libGenericCodeGen.a < │ ├── libglslang.a < │ ├── libglslang-default-resource-limits.a < │ ├── libHLSL.a < │ ├── libMachineIndependent.a < │ ├── libOGLCompiler.a < │ ├── libOSDependent.a < │ ├── libSPIRV.a < │ └── libSPVRemapper.a < └── share < └── glslang < ├── glslang-config.cmake < ├── glslang-config-version.cmake < ├── glslang-targets.cmake < └── glslang-targets-debug.cmake --- > └── lib > ├── cmake > │ ├── glslang-default-resource-limitsTargets.cmake > │ ├── glslangTargets.cmake > │ ├── glslangValidatorTargets.cmake > │ ├── HLSLTargets.cmake > │ ├── OGLCompilerTargets.cmake > │ ├── OSDependentTargets.cmake > │ ├── spirv-remapTargets.cmake > │ ├── SPIRVTargets.cmake > │ └── SPVRemapperTargets.cmake > ├── glslang > │ ├── glslang-config.cmake > │ ├── glslang-config-version.cmake > │ ├── glslang-targets.cmake > │ └── glslang-targets-debug.cmake > ├── libGenericCodeGen.a > ├── libglslang.a > ├── libglslang-default-resource-limits.a > ├── libHLSL.a > ├── libMachineIndependent.a > ├── libOGLCompiler.a > ├── libOSDependent.a > ├── libSPIRV.a > └── libSPVRemapper.a 101c100 < 15 directories, 83 files --- > 14 directories, 83 files
Also enforce target names in CMakeDeps. Since KhronosGroup/glslang#2989, glslang provides glslang-config.cmake file with CMake targets under glslang:: namespace.
* partial conan v2 support Also enforce target names in CMakeDeps. Since KhronosGroup/glslang#2989, glslang provides glslang-config.cmake file with CMake targets under glslang:: namespace. * add glslang/1.3.224.0
* partial conan v2 support Also enforce target names in CMakeDeps. Since KhronosGroup/glslang#2989, glslang provides glslang-config.cmake file with CMake targets under glslang:: namespace. * add glslang/1.3.224.0
* partial conan v2 support Also enforce target names in CMakeDeps. Since KhronosGroup/glslang#2989, glslang provides glslang-config.cmake file with CMake targets under glslang:: namespace. * add glslang/1.3.224.0
all my reviews fixed with #3063 |
As glslang ships architecture dependant files, the Config file should be installed to libdir, not datadir. See KhronosGroup#2989 (comment) for more details. Here's the diff between the install tree before and after this patch: $ diff <(tree install-datadir) <(tree install) 1c1 < install-datadir --- > install 74,99c74,98 < ├── lib < │ ├── cmake < │ │ ├── glslang-default-resource-limitsTargets.cmake < │ │ ├── glslangTargets.cmake < │ │ ├── glslangValidatorTargets.cmake < │ │ ├── HLSLTargets.cmake < │ │ ├── OGLCompilerTargets.cmake < │ │ ├── OSDependentTargets.cmake < │ │ ├── spirv-remapTargets.cmake < │ │ ├── SPIRVTargets.cmake < │ │ └── SPVRemapperTargets.cmake < │ ├── libGenericCodeGen.a < │ ├── libglslang.a < │ ├── libglslang-default-resource-limits.a < │ ├── libHLSL.a < │ ├── libMachineIndependent.a < │ ├── libOGLCompiler.a < │ ├── libOSDependent.a < │ ├── libSPIRV.a < │ └── libSPVRemapper.a < └── share < └── glslang < ├── glslang-config.cmake < ├── glslang-config-version.cmake < ├── glslang-targets.cmake < └── glslang-targets-debug.cmake --- > └── lib > ├── cmake > │ ├── glslang-default-resource-limitsTargets.cmake > │ ├── glslangTargets.cmake > │ ├── glslangValidatorTargets.cmake > │ ├── HLSLTargets.cmake > │ ├── OGLCompilerTargets.cmake > │ ├── OSDependentTargets.cmake > │ ├── spirv-remapTargets.cmake > │ ├── SPIRVTargets.cmake > │ └── SPVRemapperTargets.cmake > ├── glslang > │ ├── glslang-config.cmake > │ ├── glslang-config-version.cmake > │ ├── glslang-targets.cmake > │ └── glslang-targets-debug.cmake > ├── libGenericCodeGen.a > ├── libglslang.a > ├── libglslang-default-resource-limits.a > ├── libHLSL.a > ├── libMachineIndependent.a > ├── libOGLCompiler.a > ├── libOSDependent.a > ├── libSPIRV.a > └── libSPVRemapper.a 101c100 < 15 directories, 83 files --- > 14 directories, 83 files
This PR introduce a new and unified
glslang
CMake config package, allglslang
targets are exposed throughglslang::
CMake namespace.Prior to this PR there were several exported CMake target under various name, no package.
With those changes, and when set properly, any CMake project should be able to consume
glslang
by simply callingfind_package(glslang CONFIG)
and then pick whatever targets they need (e.g.glslang::glslang
,glslang::SPIRV
, etc.)Note that as I am not really sure which existing projects uses existing exported CMake targets via direct includes, I still provide a layer of backward compatibility and issue a warning.
I see that there are a number of pending PR/issues already (#1978, #2751, #2570, #2778 and maybe more ?) but they seems to be on hold as I do not see any progress over last months so here is my attempt to fix the issue.