diff --git a/.gitignore b/.gitignore index 6d7eb1c..c98b187 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ naval_fate run_testcase run_testcase.exe +# CMake build directories +/*build*/ + # CMake temporary files CMakeCache.txt CMakeFiles diff --git a/CMakeLists.txt b/CMakeLists.txt index 28da614..552e043 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,9 +101,20 @@ install(FILES ${docopt_HEADERS} DESTINATION include/docopt) # CMake Package include(CMakePackageConfigHelpers) -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(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 +configure_package_config_file(docopt-config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/${ConfigPackageLocation}/docopt-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/${ConfigPackageLocation}") +write_basic_package_version_file("${PROJECT_BINARY_DIR}/${ConfigPackageLocation}/docopt-config-version.cmake" + COMPATIBILITY SameMajorVersion) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ConfigPackageLocation}/docopt-config.cmake" + ${PROJECT_BINARY_DIR}/${ConfigPackageLocation}/docopt-config-version.cmake + DESTINATION "${CMAKE_INSTALL_LIBDIR}/${ConfigPackageLocation}") +install(EXPORT ${export_name} + DESTINATION "${CMAKE_INSTALL_LIBDIR}/${ConfigPackageLocation}" + NAMESPACE Docopt::) +add_library(Docopt::docopt ALIAS docopt) 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) diff --git a/docopt-config.cmake b/docopt-config.cmake.in similarity index 53% rename from docopt-config.cmake rename to docopt-config.cmake.in index 33c36c0..1782482 100644 --- a/docopt-config.cmake +++ b/docopt-config.cmake.in @@ -1 +1,5 @@ +@PACKAGE_INIT@ + include("${CMAKE_CURRENT_LIST_DIR}/docopt-targets.cmake") + +check_required_components(docopt)