-
Notifications
You must be signed in to change notification settings - Fork 454
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: Fixes for yaml-cpp and generated config #1823
Merged
doug-walker
merged 5 commits into
AcademySoftwareFoundation:main
from
FtZPetruska:cmake-config-fix
Aug 30, 2023
Merged
CMake: Fixes for yaml-cpp and generated config #1823
doug-walker
merged 5 commits into
AcademySoftwareFoundation:main
from
FtZPetruska:cmake-config-fix
Aug 30, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The check would always evaluate to true otherwise. Signed-off-by: Pierre Wendling <[email protected]>
This avoids guessing the path to the prefix. Signed-off-by: Pierre Wendling <[email protected]>
The target was renamed to `yaml-cpp::yaml-cpp`, which breaks when using the upstream CMake package over the Find module. Signed-off-by: Pierre Wendling <[email protected]>
7 tasks
12 tasks
michdolan
approved these changes
Aug 29, 2023
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.
Thanks for the fix @FtZPetruska . Looks good to me.
remia
approved these changes
Aug 29, 2023
cedrik-fuoco-adsk
approved these changes
Aug 29, 2023
This somehow broke things, now I cannot compile opencolorio with yaml-cpp 0.8.0 #1858 |
brkglvn01
pushed a commit
to brkglvn01/OpenColorIO
that referenced
this pull request
Oct 23, 2023
…tion#1823) * Use `TARGET` for the config if-statements. The check would always evaluate to true otherwise. Signed-off-by: Pierre Wendling <[email protected]> * Use PACKAGE_PREFIX_DIR from PACKAGE_INIT. This avoids guessing the path to the prefix. Signed-off-by: Pierre Wendling <[email protected]> * Add compatibility with yaml-cpp 0.8.0 target. The target was renamed to `yaml-cpp::yaml-cpp`, which breaks when using the upstream CMake package over the Find module. Signed-off-by: Pierre Wendling <[email protected]> --------- Signed-off-by: Pierre Wendling <[email protected]> Co-authored-by: Rémi Achard <[email protected]> Co-authored-by: Doug Walker <[email protected]> Signed-off-by: Brooke <[email protected]>
doug-walker
added a commit
to autodesk-forks/OpenColorIO
that referenced
this pull request
Dec 6, 2023
…tion#1823) * Use `TARGET` for the config if-statements. The check would always evaluate to true otherwise. Signed-off-by: Pierre Wendling <[email protected]> * Use PACKAGE_PREFIX_DIR from PACKAGE_INIT. This avoids guessing the path to the prefix. Signed-off-by: Pierre Wendling <[email protected]> * Add compatibility with yaml-cpp 0.8.0 target. The target was renamed to `yaml-cpp::yaml-cpp`, which breaks when using the upstream CMake package over the Find module. Signed-off-by: Pierre Wendling <[email protected]> --------- Signed-off-by: Pierre Wendling <[email protected]> Co-authored-by: Rémi Achard <[email protected]> Co-authored-by: Doug Walker <[email protected]> Signed-off-by: Doug Walker <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When packaging
yaml-cpp
0.8.0 on vcpkg, we met build issues with OpenColorIO due to how the package is linked.With the release of
yaml-cpp
0.8.0, the exported target changed fromyaml-cpp
toyaml-cpp::yaml-cpp
. This only breaks when telling CMake to use the upstream package config over theFindyaml-cpp
module.On the other hand, the upstream CMake configs have always provided a
YAML_CPP_LIBRARIES
variable that stores the target name.To fix this issue, I updated the
Findyaml-cpp
module to be compatible with the upstream config:yaml-cpp::yaml-cpp
target aliasingyaml-cpp
YAML_CPP_LIBRARIES
toyaml-cpp::yaml-cpp
When
yaml-cpp
is linked, expand theYAML_CPP_LIBRARIES
variable instead of using a target name, ensuring we always get a valid target.Lastly, in the generated config, check that neither
yaml-cpp
andyaml-cpp::yaml-cpp
are defined before callingfind_dependency
.On that note, there were a few other issues with the CMake package config:
if(NOT <target name>)
always evaluates to true,if(NOT TARGET <target name>)
should be used to check for the existence of a target.PACKAGE_PREFIX_DIR
(provided by@PACKAGE_INIT@
). The assumption that the config would always be in<prefix>/lib/cmake/OpenColorIO
is pretty fragile as a user could overwriteCMAKE_INSTALL_LIBDIR
. Similarly, vcpkg relocates CMake packages after installation toshare/<package name>
(while updatingPACKAGE_PREFIX_DIR
), also breaking that assumption.An alternative I considered was to leave the Find module intact and to handle it internally as such:
And in the exported CMake config:
Let me know if you prefer this solution instead!