-
Notifications
You must be signed in to change notification settings - Fork 215
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
CMake Configuration can fail when building as a code dependency due to find_package(glslang CONFIG) #1271
Comments
There's been a bunch of discussion about this on a PR, so I'll quote it all here: Robert:
Nolan:
Robert:
Me:
Also me:
Nolan:
|
vsgFramework is currently broken. We made the decision not to support glslang via FetchContent because of upstream problems that make it a pain, and because glslang's maintainers recommend the build/install/find approach as the only reliable one, so aren't going to prioritise fixing anything. I did some work to fix upstream problems, but at least one of them would need major changes, so they're unlikely to accept it.
That would explain the difference in behaviour. I didn't know CPM did this as all of its examples are for libraries that don't have any dependencies they don't bundle. Looking into it, it doesn't sound like it's an entirely finished feature, so I think it's a decently safe bet that CPM could start also creating the config files like plain FetchContent would in recent versions of CMake, or register itself as a dependency provider to intercept the Without CPM, it's considered bad practice to use
I just tried a DLL build of glslang, and it seems pretty broken. I've reported it here KhronosGroup/glslang#3716. The import libraries aren't supposed to be missing, and it even breaks several of glslang's own targets, but presumably, you've not tried building those.
This is one of the upstream problems I mentioned. If things are working properly, then you need install to work properly for your dependencies if they're DLLs/ This was something that was broken on purpose by glslang with KhronosGroup/glslang#3439 by an actual LunarG employee. KhronosGroup/glslang#3508 fixes it (or maybe only partially fixes it - it was months ago that I looked into it) if you explicitly pass in an option, so you might want to try that. Anyway, I'm able to build VSG as a static or dynamic library and link it with static glslang just fine when glslang is built, installed and
You need to tell glslang's maintainers this, as all the difficulties stem from them disagreeing, and making a big mess. Fixing that mess would require days of development and then based on my experience of getting PRs to glslang merged, weeks or months of politicking to maybe get the changes merged or maybe get them rejected. I did try the make everything nice upstream so FetchContent is feasible approach, but had to give up as it was eating too much valuable time. There are ways to work around lots of the problems, and I did manage to get fixes merged for some of the others, but it even if we tolerated all the necessary ugliness in this repo to do that, it could all fall apart when glslang makes another change that breaks this workflow. SummaryA minor CPM issue plus glslang doesn't support being used with FetchContent so we can't support using it via FetchContent. As a temporary solution, you should be able to |
Thank so much for going down this rabbit hole with me @AnyOldName3! I really appreciate the patience as I get situated with this issue. I'm not one for politicking either - I try to avoid it like the plague. I really prefer just being able to get things done, instead of trying to change people's point-of-view. That's why I appreciate you having the patience to explain this all to me. Seeing the issue as it is now - this all makes sense: If the upstream dependency doesn't work with FetchContent, then any code dependency build that relies on the feature will be horribly broken, and there's nothing that we could permanently do to address it, unless all dependencies agree to hold up their end of the compatibility bargain. Also - I double-checked my local build - you're right about no symbols being exported. That seems like a serious issue as well! It makes sense now that the import .libs are not being generated. It also explains why building as a static library worked, since those don't rely on a dynamic linker. I'll try the workaround with I don't think I'm in a position to contribute much to the discussion in glslang - however I'm happy to add another voice of discontent on their repo since, to me, it's clearly non-supportive of a useful workflow when it could be if it were just built with it in-mind. |
For anyone following along - @AnyOldName3's open issue in glslang is here: KhronosGroup/glslang#3509 |
Thanks for all the discussion guys. glslang has been painful dependency to have :-| If there is an alternative for compiling high level shaders into SPIR-V comes into existence that is easy to integrate I'll very happily adopt it. |
I've ended up working around the issue using this cmake code:
It's not pretty. It essentially downloads, configures, builds, and installs glslang at parent project configure time - then sets glslang_DIR to the install directory. It's probably robust enough to use in vsg-Framework. It might need some error checking, cleanup, and checks to speed up cached builds. But that's up to you guys. We might want to run some tests to ensure robustness. It could probably also be made more slick by using an externally-sourced SPIRV-tools. |
If you're doing everything at configure time, then ExternalProject is a more appropriate tool than FetchContent https://cmake.org/cmake/help/latest/module/ExternalProject.html. |
I'm open to revisiting the use of FetchContent in vsgFramework, originally I was concerned about supporting older versions of CMake that widely used linux distro's were still on, but it's now 2024 not 2018 so we can probably relax the CMake version constraint. We'd need to check what CMake versions are available on the main platforms, then use that as a starting place. To get things started, the laptop I'm on now has Kubuntu 24.04 which has CMake 3.28.3. |
My Kubuntu 22.04 systems has CMake 3.22.1 |
Looking online for older Ubuntu versions: Ubunutu 20.04 has cmake 3.16.3 It's more important that the VSG itself can still work with older CMake versions - the required version presently sits at 3.7. It would interesting to see what other older distros have as we might be able to set a more modern CMake as minimum. For vsgFramework it's more of a niche vsgFramework, requires 3.14, but we potentially could set it 3.16.3 so still work on the Ubuntu 20.04 era OS's. I don't know what that might gives us in terms of additional CMake capabilities. If we set 22.04 era as a minimum for vsgFramework then we can use CMake 3.22.1 as a base. |
|
I patched the above code together quickly over the weekend. I didn't see an immediate way to set-up a dependency relationship between an If there's a better way, I'm happy to update the code! |
After the |
@robertosfield How far back is vsg required to hold compatibility for Linux and CMake? |
That's the very question I'm asking myself by listing what different OS versions support which CMake versions. I don't want to orphan support for users stuck on older OS's but if the number of affected users is small and they have a path for installing a more modern CMake version then we can potentially just ask them to upgrade. The VSG community is like all open source communities - you don't get to find out all the different combinations that users are using the software until they raise a flag a problem saying they've come across a problem. You can ask for feedback and this can help, but these calls on go so far in reaching end users. It's only after you've made a decision and changed something do you get to find out that causes a problem for some users. |
Describe the bug
When including vsg as a code dependency in another project (as a submodule or FetchContent) AND the encompassing project is using glslang as a code dependency - vsg can fail to configure because the
find_package(glslang)
command is forced into CONFIG mode:See
VulkanSceneGraph/CMakeLists.txt
Line 47 in b64dbb2
To Reproduce
Steps to reproduce the behavior:
Expected behavior
CONFIG should be removed - as CMake can gracefully fallback to CONFIG mode if MODULE mode fails.
The text was updated successfully, but these errors were encountered: