Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add CMake imported target for docopt library#159

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
eaaltonen wants to merge3 commits intodocopt:master
base:master
Choose a base branch
Loading
fromvaisala-oss:add-imported-target

Conversation

@eaaltonen
Copy link

This PR writes the CMake config-file package usingCMakePackageConfigHelpers and exports the target as aDocopt::docopt imported target.

This allows developers to install and use the library without necessarily requiringroot permission by:

  1. Installing docopt with-DCMAKE_INSTALL_PREFIX="${HOME}/wherever"
  2. then using with-DCMAKE_PREFIX_PATH="${HOME}/wherever" and linking to imported targetDocopt::docopt.

Keeping in mind the newly releasedFetchContent and find_package() integration, also add an alias target so thatDocopt::docopt can be linked to regardless of whether the build uses a prebuilt package or fetches the sources.

Using a separate build directory is a very common way of using CMake soadd an ignore pattern for those.
DESTINATION"${CMAKE_INSTALL_LIBDIR}/${ConfigPackageLocation}")
install(EXPORT${export_name}
DESTINATION"${CMAKE_INSTALL_LIBDIR}/${ConfigPackageLocation}"
NAMESPACE Docopt::)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Regarding the name:

  • is currentDocopt::docopt good
  • should it beDocopt.cpp::docopt
  • something else ?

install(FILES docopt-config.cmake${PROJECT_BINARY_DIR}/docopt-config-version.cmakeDESTINATION"${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
Copy link
Author

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.

Eero Aaltonen added2 commitsOctober 17, 2022 14:42
Write our CMake config-file package using the`configure_package_config_file` function defined inCMakePackageConfigHelpers.cmakeand export our library in a namespace so that it can be used as animported target.
With the alias, the `Docopt::docopt` target can be linked to regardlessof whether the consuming project uses `find_package` or`add_subdirectory`.
@eaaltonen
Copy link
Author

added missing newline todocopt-config.cmake.in.

@eaaltonen
Copy link
Author

@jaredgrubb : if you could take a look? I will be submitting packaging to Buildroot soonish.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@eaaltonen

[8]ページ先頭

©2009-2025 Movatter.jp