Skip to content

Commit

Permalink
cmake: create and install pkg-config file
Browse files Browse the repository at this point in the history
This was one requirement in rafaelsteil#27 to make it easier for other, non CMake
projects to use libcgi.

Signed-off-by: Alexander Dahl <[email protected]>
  • Loading branch information
LeSpocky committed Feb 24, 2017
1 parent 3874f4d commit 4651b37
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}")

set(CGI_DESCRIPTION "A C library to build CGI applications.")
set(CGI_URL "https://github.com/rafaelsteil/libcgi")

# includes
include(CMakePackageConfigHelpers) # cmake 2.8.8
include(FeatureSummary)
Expand Down Expand Up @@ -45,6 +48,17 @@ install(FILES
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)

# pkg-config stuff
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/libcgi.pc.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/libcgi.pc"
@ONLY
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/libcgi.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)

# feature summary
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
feature_summary(WHAT ALL)
Expand All @@ -56,7 +70,7 @@ set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A C library to build CGI applications.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CGI_DESCRIPTION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES "/\\\\.kdev4/;\\\\.kdev4$;/\\\\.git/;\\\\.gitignore;\\\\.swp$")
include(CPack)
9 changes: 9 additions & 0 deletions libcgi.pc.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

Name: libcgi
Description: @CGI_DESCRIPTION@
URL: @CGI_URL@
Version: @PROJECT_VERSION@
Libs: -L${libdir} -lcgi
Cflags: -I${includedir}

0 comments on commit 4651b37

Please sign in to comment.