From 12089e4f599489b54ef1e15314d11b4427bfbafa Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Tue, 24 Dec 2013 18:46:31 +0100 Subject: [PATCH] Move .pc generation to a dedicated script (#55). --- CMakeLists.txt | 28 ++---------------------- build/cmake/CreatePkgConfigFile.cmake | 31 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 build/cmake/CreatePkgConfigFile.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9623b7899..d693fa767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1518,32 +1518,8 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) ADD_DEFINITIONS(-DHAVE_CONFIG_H) -# Generate a libarchive.pc like autotools for pkg-config -SET(prefix ${CMAKE_INSTALL_PREFIX}) -SET(exec_prefix \${prefix}) -SET(libdir \${exec_prefix}/lib) -SET(includedir \${prefix}/include) -# Now, this is not particularly pretty, nor is it terribly accurate... -# Loop over all our additional libs -FOREACH(mylib ${ADDITIONAL_LIBS}) - # Extract the filename from the absolute path - GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE) - # Strip the lib prefix - STRING(REGEX REPLACE "^lib" "" mylib_name ${mylib_name}) - # Append it to our LIBS string - SET(LIBS "${LIBS} -l${mylib_name}") -ENDFOREACH() -# libxml2 is easier, since it's already using pkg-config -FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS}) - SET(LIBS "${LIBS} ${mylib}") -ENDFOREACH() -# FIXME: The order is all wrong, thus there's a good chance it'll make some binutils versions unhappy... -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in - ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc - @ONLY) -# And install it, of course ;). -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc - DESTINATION "lib/pkgconfig") +# Handle generation of the libarchive.pc file for pkg-config +INCLUDE(CreatePkgConfigFile) # # Register installation of PDF documents. diff --git a/build/cmake/CreatePkgConfigFile.cmake b/build/cmake/CreatePkgConfigFile.cmake new file mode 100644 index 000000000..f96bbef00 --- /dev/null +++ b/build/cmake/CreatePkgConfigFile.cmake @@ -0,0 +1,31 @@ +# - Generate a libarchive.pc like autotools for pkg-config +# + +# Set the required variables (we use the same input file as autotools) +SET(prefix ${CMAKE_INSTALL_PREFIX}) +SET(exec_prefix \${prefix}) +SET(libdir \${exec_prefix}/lib) +SET(includedir \${prefix}/include) +# Now, this is not particularly pretty, nor is it terribly accurate... +# Loop over all our additional libs +FOREACH(mylib ${ADDITIONAL_LIBS}) + # Extract the filename from the absolute path + GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE) + # Strip the lib prefix + STRING(REGEX REPLACE "^lib" "" mylib_name ${mylib_name}) + # Append it to our LIBS string + SET(LIBS "${LIBS} -l${mylib_name}") +ENDFOREACH() +# libxml2 is easier, since it's already using pkg-config +FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS}) + SET(LIBS "${LIBS} ${mylib}") +ENDFOREACH() +# FIXME: The order of the libraries doesn't take dependencies into account, +# thus there's a good chance it'll make some binutils versions unhappy... +# This only affects Libs.private (looked up for static builds) though. +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc + @ONLY) +# And install it, of course ;). +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc + DESTINATION "lib/pkgconfig") -- 2.47.2