CMake: Fixes for yaml-cpp and generated config#1823
Merged
doug-walker merged 5 commits intoAug 30, 2023
Conversation
The check would always evaluate to true otherwise. Signed-off-by: Pierre Wendling <pierre.wendling.4@gmail.com>
This avoids guessing the path to the prefix. Signed-off-by: Pierre Wendling <pierre.wendling.4@gmail.com>
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 <pierre.wendling.4@gmail.com>
7 tasks
12 tasks
michdolan
approved these changes
Aug 29, 2023
Collaborator
michdolan
left a comment
There was a problem hiding this comment.
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
Contributor
|
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 <pierre.wendling.4@gmail.com> * Use PACKAGE_PREFIX_DIR from PACKAGE_INIT. This avoids guessing the path to the prefix. Signed-off-by: Pierre Wendling <pierre.wendling.4@gmail.com> * 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 <pierre.wendling.4@gmail.com> --------- Signed-off-by: Pierre Wendling <pierre.wendling.4@gmail.com> Co-authored-by: Rémi Achard <remiachard@gmail.com> Co-authored-by: Doug Walker <doug.walker@autodesk.com> Signed-off-by: Brooke <beg9562@rit.edu>
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 <pierre.wendling.4@gmail.com> * Use PACKAGE_PREFIX_DIR from PACKAGE_INIT. This avoids guessing the path to the prefix. Signed-off-by: Pierre Wendling <pierre.wendling.4@gmail.com> * 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 <pierre.wendling.4@gmail.com> --------- Signed-off-by: Pierre Wendling <pierre.wendling.4@gmail.com> Co-authored-by: Rémi Achard <remiachard@gmail.com> Co-authored-by: Doug Walker <doug.walker@autodesk.com> Signed-off-by: Doug Walker <Doug.Walker@autodesk.com>
This file contains hidden or 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
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-cpp0.8.0 on vcpkg, we met build issues with OpenColorIO due to how the package is linked.With the release of
yaml-cpp0.8.0, the exported target changed fromyaml-cpptoyaml-cpp::yaml-cpp. This only breaks when telling CMake to use the upstream package config over theFindyaml-cppmodule.On the other hand, the upstream CMake configs have always provided a
YAML_CPP_LIBRARIESvariable that stores the target name.To fix this issue, I updated the
Findyaml-cppmodule to be compatible with the upstream config:yaml-cpp::yaml-cpptarget aliasingyaml-cppYAML_CPP_LIBRARIEStoyaml-cpp::yaml-cppWhen
yaml-cppis linked, expand theYAML_CPP_LIBRARIESvariable instead of using a target name, ensuring we always get a valid target.Lastly, in the generated config, check that neither
yaml-cppandyaml-cpp::yaml-cppare 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/OpenColorIOis 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!