-
Notifications
You must be signed in to change notification settings - Fork 146
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
Add CMake imported target for docopt library #159
base: master
Are you sure you want to change the base?
Conversation
Using a separate build directory is a very common way of using CMake so add an ignore pattern for those.
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${ConfigPackageLocation}") | ||
install(EXPORT ${export_name} | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${ConfigPackageLocation}" | ||
NAMESPACE Docopt::) |
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.
Regarding the name:
- is current
Docopt::docopt
good - should it be
Docopt.cpp::docopt
- something else ?
install(FILES docopt-config.cmake ${PROJECT_BINARY_DIR}/docopt-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/docopt") | ||
install(EXPORT ${export_name} DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/docopt") | ||
set(ConfigPackageLocation "cmake/docopt") | ||
# Unix layout, ref https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure |
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.
There's at least two valid choices here, so I'd like to check the project author's preference here:
- unix layout (current)
- picking a layout according the current / specified OS.
Write our CMake config-file package using the `configure_package_config_file` function defined in CMakePackageConfigHelpers.cmake and export our library in a namespace so that it can be used as an imported target.
With the alias, the `Docopt::docopt` target can be linked to regardless of whether the consuming project uses `find_package` or `add_subdirectory`.
01ad933
to
1ea7bd5
Compare
added missing newline to |
@jaredgrubb : if you could take a look? I will be submitting packaging to Buildroot soonish. |
This PR writes the CMake config-file package using CMakePackageConfigHelpers and exports the target as a
Docopt::docopt
imported target.This allows developers to install and use the library without necessarily requiring
root
permission by:-DCMAKE_INSTALL_PREFIX="${HOME}/wherever"
-DCMAKE_PREFIX_PATH="${HOME}/wherever"
and linking to imported targetDocopt::docopt
.Keeping in mind the newly released FetchContent and find_package() integration, also add an alias target so that
Docopt::docopt
can be linked to regardless of whether the build uses a prebuilt package or fetches the sources.