vcpkg/ports/baresip-libre/fix-static-library-build.patch

87 lines
2.8 KiB
Diff
Raw Normal View History

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 84a507f..d400e3b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,7 +99,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
endif()
set(re_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake)
-find_package(re CONFIG REQUIRED)
+include("${CMAKE_CURRENT_LIST_DIR}/cmake/re-config.cmake")
list(APPEND RE_DEFINITIONS
-DRE_VERSION="${PROJECT_VERSION_FULL}"
@@ -648,7 +648,7 @@ endif()
if(LIBRE_BUILD_STATIC)
list(APPEND RE_INSTALL_TARGETS re)
add_library(re STATIC $<TARGET_OBJECTS:re-objs>)
- target_link_libraries(re PUBLIC ${RE_LIBS})
+ target_link_libraries(re PRIVATE ${RE_LIBS})
target_include_directories(re PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
@@ -704,6 +704,9 @@ configure_file(packaging/libre.pc.in libre.pc @ONLY)
install(TARGETS ${RE_INSTALL_TARGETS}
EXPORT libre
+ RUNTIME
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
+ COMPONENT Libraries
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Libraries
@@ -722,7 +725,9 @@ install(FILES ${HEADERS}
install(EXPORT libre
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libre
+ FILE libre-targets.cmake
NAMESPACE libre::
+ COMPONENT Development
)
if(LIBRE_BUILD_SHARED)
@@ -734,12 +739,8 @@ if(LIBRE_BUILD_SHARED)
)
endif()
-install(FILES cmake/re-config.cmake
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/re
- COMPONENT Development
-)
-
-install(FILES cmake/libre-config.cmake
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/libre-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/libre-config.cmake" @ONLY)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/libre-config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libre
COMPONENT Development
)
diff --git a/cmake/libre-config.cmake b/cmake/libre-config.cmake
index 0965b84..e8548a0 100644
--- a/cmake/libre-config.cmake
+++ b/cmake/libre-config.cmake
@@ -1 +1,23 @@
-include("${CMAKE_CURRENT_LIST_DIR}/libre.cmake")
+if("@LIBRE_BUILD_STATIC@")
+ include(CMakeFindDependencyMacro)
+ find_dependency(Threads)
+ if("@USE_OPENSSL@")
+ find_dependency(OpenSSL)
+ endif()
+ if("@ZLIB_FOUND@")
+ find_dependency(ZLIB)
+ endif()
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/libre-targets.cmake")
+
+# convenience target libre::libre for uniform usage
+if(NOT TARGET libre::libre)
+ if(TARGET libre::re_shared AND (BUILD_SHARED_LIBS OR NOT TARGET libre::re))
+ add_library(libre::libre INTERFACE IMPORTED)
+ set_target_properties(libre::libre PROPERTIES INTERFACE_LINK_LIBRARIES libre::re_shared)
+ elseif(TARGET libre::re AND (NOT BUILD_SHARED_LIBS OR NOT TARGET libre::re_shared))
+ add_library(libre::libre INTERFACE IMPORTED)
+ set_target_properties(libre::libre PROPERTIES INTERFACE_LINK_LIBRARIES libre::re)
+ endif()
+endif()