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
Document this project's CMake integration options #69
Comments
@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) |
@athrun22 Thanks! I've created #75 to track this suggestion, and I'll add comments there... |
Things we could include:
|
@claremacrae I think |
This comment will be helpful for these docs, too: |
Here's the evolving CMake docs page I've started on: https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/CMakeIntegration.md#top |
Now most of our tests are not executed if this projected has been added inside another one.
@claremacrae Thanks for the CMake Integrations section! It looks good. My only quibble is the two occurrences of "on" in the last paragraph should probably be |
Thanks @jwillikers I'm putting this down now, as of 37f07dd. I included a bunch of examples as they were initially slightly hard-won figuring out the different options, so I didn't want to lose them, and I think they may help others. I couldn't see the lower-case "on" you mentioned, so I suspect I capitalised it - or removed it - along the way. Even though I've closed the issue, I would definitely welcome any feedback from anyone who spends the time to read the doc! |
As our CMake scripts become more standard and more flexible, we should have a page of documentation describing the supported options.
This might be a good example to look at:
https://github.com/catchorg/Catch2/blob/master/docs/cmake-integration.md#top
See also this evolving project, in which I'm exploring, and testing, options for using 3rd-party dependencies:
https://github.com/claremacrae/ApprovalTests.cpp.Builds
The text was updated successfully, but these errors were encountered: