diff --git a/CMakeLists.txt b/CMakeLists.txt index 117e2c7b7..355355ec0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -656,6 +656,9 @@ if(LIBRE_BUILD_STATIC) if(MSVC) set_target_properties(re PROPERTIES OUTPUT_NAME "re-static") + if(NOT LIBRE_BUILD_SHARED) + set(PC_LIBNAME "re-static") + endif() endif() endif() @@ -668,6 +671,28 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) add_subdirectory(packaging) endif() +if(NOT PC_LIBNAME) + set(PC_LIBNAME "re") +endif() +set(PC_REQUIRES "") +set(PC_LINKLIBS "") +foreach(item IN LISTS RE_LIBS) + if(item STREQUAL "Threads::Threads") + list(APPEND PC_LINKLIBS ${CMAKE_THREADS_LIBS_INIT}) + elseif(item STREQUAL "OpenSSL::Crypto") + list(APPEND PC_REQUIRES "libcrypto") + elseif(item STREQUAL "OpenSSL::SSL") + list(APPEND PC_REQUIRES "libssl") + elseif(item STREQUAL "ZLIB::ZLIB") + list(APPEND PC_REQUIRES "zlib") + elseif(item MATCHES "^-|/") + list(APPEND PC_LINKLIBS "${item}") + else() + list(APPEND PC_LINKLIBS "-l${item}") + endif() +endforeach() +list(JOIN PC_LINKLIBS " " PC_LINKLIBS) +list(JOIN PC_REQUIRES " " PC_REQUIRES) configure_file(packaging/libre.pc.in libre.pc @ONLY) diff --git a/packaging/libre.pc.in b/packaging/libre.pc.in index 5817066f0..2df8f6c6a 100644 --- a/packaging/libre.pc.in +++ b/packaging/libre.pc.in @@ -7,6 +7,7 @@ Name: libre Description: @CMAKE_PROJECT_DESCRIPTION@ Version: @PROJECT_VERSION@ URL: @CMAKE_PROJECT_HOMEPAGE_URL@ -Libs: -L${libdir} -lre -Libs.private: -L${libdir} -lre -ldl -lssl -lcrypto -lz -lpthread +Libs: -L${libdir} -l@PC_LIBNAME@ +Libs.private: @PC_LINKLIBS@ +Requires.private: @PC_REQUIRES@ Cflags: -I${includedir}