-
Notifications
You must be signed in to change notification settings - Fork 53
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
Create a namespaced CMake target for ApprovalTests #75
Comments
Here's the explanation, copied from the original issue: @claremacrae, a namespaced CMake target for ApprovalTests would be good to create before this documentation is done. By adding an aliased CMake target for ApprovalTests that prefixes a namespace, users can switch between using an installed version of the library - if support for An example might make this more clear. 🤔 # Use an installed version of ApprovalTests
find_package(ApprovalTests 7.0.0 REQUIRED)
add_executable(my-test PRIVATE main.cpp)
# According to standard practice, imported targets are prefixed with a namespace
target_link_libraries(my-test PRIVATE ApprovalTests::ApprovalTests) This links to our current setup of ApprovalTests when using add_subdirectory(ApprovalTests)
add_executable(my-test PRIVATE main.cpp)
# Notice the target name is different. This requires the user to change the library name.
target_link_libraries(my-test PRIVATE ApprovalTests) This links to our current setup of ApprovalTests when using add_subdirectory(ApprovalTests)
add_executable(my-test PRIVATE main.cpp)
# Target name is the same and this requires no change by the user.
target_link_libraries(my-test PRIVATE ApprovalTests::ApprovalTests) Aliasing the ApprovalTests library in CMake is as simple as adding the following somewhere after defining the add_library(ApprovalTests::ApprovalTests ALIAS ApprovalTests) |
I'd been wondering whether to add an aliased target - this is a good explanation of one reason to do so, that's new to me... A reason that I was aware of is that in |
@claremacrae Right you are! I use alias libraries internally for this very reason. |
@jwillikers, does the above change look OK? Any feedback on the documentation change? Many thanks. |
For details, see the really clear explanation by @athrun22 in: #69 (comment)
The text was updated successfully, but these errors were encountered: