Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Also support creating relocatable pkgconfig
Using the pgk-config derived variable `pcfiledir` provides an option
to create a package which the user can install to a location of their
choosing. The prefix is determined at runtime from where the pkgconfig
file is found.

Signed-off-by: Eero Aaltonen <eero.aaltonen@vaisala.com>
  • Loading branch information
Eero Aaltonen committed Aug 17, 2023
commit 9eba9995b3b5f110269e8b8feda61ea0508e9f70
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include(GNUInstallDirs)
option(WITH_TESTS "Build tests." OFF)
option(WITH_EXAMPLE "Build example." OFF)
option(USE_BOOST_REGEX "Replace std::regex with Boost.Regex" OFF)
option(PKGCONFIG_RELOCATABLE "Create a pkgconfig file with relocatable path" OFF)

#============================================================================
# Internal compiler options
Expand Down Expand Up @@ -105,6 +106,11 @@ write_basic_package_version_file("${PROJECT_BINARY_DIR}/docopt-config-version.cm
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")

if(PKGCONFIG_RELOCATABLE)
set(PKGCONFIG_PREFIX "\${pcfiledir}/../..")
else()
set(PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docopt.pc.in ${CMAKE_CURRENT_BINARY_DIR}/docopt.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/docopt.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

Expand Down
5 changes: 3 additions & 2 deletions docopt.pc.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
includedir=@CMAKE_INSTALL_PREFIX@/include/docopt
prefix=@PKGCONFIG_PREFIX@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/include/docopt

Name: docopt.cpp
Description: C++11 port of docopt
Expand Down