diff --git a/.pkg-config/pegtl.pc.in b/.pkg-config/pegtl.pc.in new file mode 100644 index 00000000..daf6c07f --- /dev/null +++ b/.pkg-config/pegtl.pc.in @@ -0,0 +1,7 @@ +includedir="@CMAKE_INSTALL_PREFIX@/@PEGTL_INSTALL_INCLUDE_DIR@" + +Name: @PROJECT_NAME@ +Description: @CMAKE_PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ +URL: @CMAKE_PROJECT_HOMEPAGE_URL@ +Cflags: -I${includedir} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 53bc9333..1df6fa02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ file(READ "${CMAKE_CURRENT_LIST_DIR}/include/tao/pegtl/version.hpp" version_hpp_ string(REGEX MATCH "#define TAO_PEGTL_VERSION \"([^\"]+)\"" _ ${version_hpp_data}) set(PEGTL_VERSION "${CMAKE_MATCH_1}") -project(pegtl VERSION ${PEGTL_VERSION} LANGUAGES CXX) +project(pegtl VERSION ${PEGTL_VERSION} DESCRIPTION "The Parsing Expression Grammar Template Library" HOMEPAGE_URL https://github.com/taocpp/PEGTL LANGUAGES CXX) set(PEGTL_IS_MAIN_PROJECT OFF) if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) @@ -37,6 +37,7 @@ mark_as_advanced(${PROJECT_NAME}_DIR) set(PEGTL_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory") set(PEGTL_INSTALL_DOC_DIR "share/doc/tao/pegtl" CACHE STRING "The installation doc directory") set(PEGTL_INSTALL_CMAKE_DIR "share/pegtl/cmake" CACHE STRING "The installation cmake directory") +set(PEGTL_INSTALL_PKGCONFIG_DIR "share/pkgconfig" CACHE STRING "The installation pkgconfig directory") # define a header-only library add_library(pegtl INTERFACE) @@ -62,9 +63,12 @@ if(PEGTL_BUILD_EXAMPLES) add_subdirectory(src/example/pegtl) endif() -# Make package findable +# Make package findable by CMake configure_file(.cmake/pegtl-config.cmake.in pegtl-config.cmake @ONLY) +# Make package findable by pkg-config +configure_file(.pkg-config/pegtl.pc.in pegtl.pc @ONLY) + # Ignore pointer width differences since this is a header-only library unset(CMAKE_SIZEOF_VOID_P) @@ -82,6 +86,7 @@ install(EXPORT pegtl-targets ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pegtl-config-version.cmake DESTINATION ${PEGTL_INSTALL_CMAKE_DIR}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pegtl.pc DESTINATION ${PEGTL_INSTALL_PKGCONFIG_DIR}) install(DIRECTORY include/ DESTINATION ${PEGTL_INSTALL_INCLUDE_DIR}) install(FILES LICENSE_1_0.txt DESTINATION ${PEGTL_INSTALL_DOC_DIR})