Улучшена генерация файла pkg-config

This commit is contained in:
Andrei Astafev 2020-04-22 22:25:22 +03:00
parent c73c31b380
commit ea2b322df6
2 changed files with 23 additions and 2 deletions

View File

@ -1,4 +1,14 @@
function(generate_pkgconfig library_name) function(generate_pkgconfig library_name)
configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${library_name}.pc) set(options)
install(FILES ${CMAKE_BINARY_DIR}/${library_name}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) set(oneValueArgs COMPONENT INSTALL_LIBRARY)
set(multiValueArgs)
cmake_parse_arguments(_PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(${_PKG_INSTALL_LIBRARY})
configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${library_name}.pc)
else()
configure_file(${CMLIB_MODULE_DIR}/pc/lib-header-only.pc.in ${CMAKE_BINARY_DIR}/${library_name}.pc)
endif()
install(FILES ${CMAKE_BINARY_DIR}/${library_name}.pc COMPONENT ${_PKG_COMPONENT} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endfunction() endfunction()

11
pc/lib-header-only.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@
Name: @library_name@
Description: @library_name@ library
Version: @PROJECT_VERSION@
Requires:
Cflags: -I@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@