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.
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 is a great addition for improving the consumer experience! However, adding this alias unconditionally could break builds for users who have already implemented the workaround described in the pull request description (i.e., they have their own
add_library(reflectcpp::reflectcpp ALIAS reflectcpp)).To make this change more robust and backward-compatible, it's a good practice to check if the target already exists before creating the alias.
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.
@gemini-code-assist Will not work if alias library is declared after add_subdirectory or FetchContentMakeAvailable. So even with that a breaking change.
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.
You raise a valid point, BestITUserEUW. The
if(NOT TARGET reflectcpp::reflectcpp)check primarily prevents redefinition errors if the target were to be defined within thereflectcppproject's own CMake processing or if a user's workaround was placed before thereflectcppproject's inclusion in their top-levelCMakeLists.txt.However, you are correct that if a user has an
add_library(reflectcpp::reflectcpp ALIAS reflectcpp)workaround in their ownCMakeLists.txtthat is processed afterreflectcpp'sCMakeLists.txt(which now defines this alias), it will indeed lead to a redefinition error. This is an unavoidable consequence of the library now officially providing thereflectcpp::reflectcpptarget.The intent of this PR is to standardize the availability of
reflectcpp::reflectcpp. When a library starts providing a target that was previously a common workaround, users who implemented that workaround will need to remove it from their build scripts. While this might require a minor adjustment for some existing users, it ultimately leads to a more consistent and robust build experience for everyone consumingreflectcpp.