From f5ba0929a243701f53b5a3dba3591d187c91bb25 Mon Sep 17 00:00:00 2001 From: Stephan Creutz Date: Sun, 4 Apr 2021 12:11:50 +0200 Subject: [PATCH] Improve docopt-config.cmake in case of Boost regex This commit declares the transitive dependency to Boost in case docopt is build with Boost regex support. In this way, the user doesn't need to declare the dependency to Boost manually. --- CMakeLists.txt | 6 +++++- docopt-config.cmake | 1 - docopt-config.cmake.in | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) delete mode 100644 docopt-config.cmake create mode 100644 docopt-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index feff32e..2005677 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,8 +125,12 @@ install(FILES ${docopt_HEADERS} DESTINATION include/docopt) # CMake Package include(CMakePackageConfigHelpers) +configure_package_config_file( + docopt-config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/docopt-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/docopt") write_basic_package_version_file("${PROJECT_BINARY_DIR}/docopt-config-version.cmake" COMPATIBILITY SameMajorVersion) -install(FILES docopt-config.cmake ${PROJECT_BINARY_DIR}/docopt-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/docopt") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/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") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docopt.pc.in ${CMAKE_CURRENT_BINARY_DIR}/docopt.pc @ONLY) diff --git a/docopt-config.cmake b/docopt-config.cmake deleted file mode 100644 index 33c36c0..0000000 --- a/docopt-config.cmake +++ /dev/null @@ -1 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/docopt-targets.cmake") diff --git a/docopt-config.cmake.in b/docopt-config.cmake.in new file mode 100644 index 0000000..2045052 --- /dev/null +++ b/docopt-config.cmake.in @@ -0,0 +1,10 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +if(@USE_BOOST_REGEX@) + find_dependency(Boost 1.53 COMPONENTS regex) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/docopt-targets.cmake") + +check_required_components(docopt)