vcpkg/ports/libdatachannel/fix-for-vcpkg.patch

103 lines
4.0 KiB
Diff
Raw Normal View History

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 14c1ecc..1a46b84 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -181,21 +181,10 @@ set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
-add_subdirectory(deps/plog)
+find_library(USRSCTP_LIBRARY usrsctp REQUIRED)
+find_path(PLOG_INCLUDE_DIRS "plog/Appenders/AndroidAppender.h")
-option(sctp_build_programs 0)
-option(sctp_build_shared_lib 0)
-set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
-add_subdirectory(deps/usrsctp EXCLUDE_FROM_ALL)
-if (MSYS OR MINGW)
- target_compile_definitions(usrsctp PUBLIC -DSCTP_STDINT_INCLUDE=<stdint.h>)
-endif()
-if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- target_compile_options(usrsctp PRIVATE -Wno-error=format-truncation)
-endif()
-add_library(Usrsctp::Usrsctp ALIAS usrsctp)
-
-add_library(datachannel SHARED
+add_library(datachannel
${LIBDATACHANNEL_SOURCES}
${LIBDATACHANNEL_HEADERS}
${LIBDATACHANNEL_IMPL_SOURCES}
@@ -213,17 +202,17 @@ set_target_properties(datachannel-static PROPERTIES
VERSION ${PROJECT_VERSION}
CXX_STANDARD 17)
-target_include_directories(datachannel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(datachannel PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
-target_link_libraries(datachannel PUBLIC Threads::Threads plog::plog)
-target_link_libraries(datachannel PRIVATE Usrsctp::Usrsctp)
+target_include_directories(datachannel PRIVATE ${PLOG_INCLUDE_DIRS})
+target_link_libraries(datachannel PUBLIC Threads::Threads ${USRSCTP_LIBRARY})
target_include_directories(datachannel-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
-target_link_libraries(datachannel-static PUBLIC Threads::Threads plog::plog)
-target_link_libraries(datachannel-static PRIVATE Usrsctp::Usrsctp)
+target_include_directories(datachannel-static PRIVATE ${PLOG_INCLUDE_DIRS})
+target_link_libraries(datachannel-static PUBLIC Threads::Threads ${USRSCTP_LIBRARY})
if(WIN32)
target_link_libraries(datachannel PUBLIC ws2_32) # winsock2
@@ -295,11 +284,11 @@ if (USE_NICE)
target_link_libraries(datachannel PRIVATE LibNice::LibNice)
target_link_libraries(datachannel-static PRIVATE LibNice::LibNice)
else()
- add_subdirectory(deps/libjuice EXCLUDE_FROM_ALL)
+ find_package(libjuice CONFIG REQUIRED)
target_compile_definitions(datachannel PRIVATE USE_NICE=0)
target_compile_definitions(datachannel-static PRIVATE USE_NICE=0)
- target_link_libraries(datachannel PRIVATE LibJuice::LibJuiceStatic)
- target_link_libraries(datachannel-static PRIVATE LibJuice::LibJuiceStatic)
+ target_link_libraries(datachannel PRIVATE LibJuice::juice)
+ target_link_libraries(datachannel-static PRIVATE LibJuice::juice)
endif()
if(CAPI_STDCALL)
@@ -310,7 +299,11 @@ endif()
add_library(LibDataChannel::LibDataChannel ALIAS datachannel)
add_library(LibDataChannel::LibDataChannelStatic ALIAS datachannel-static)
-install(TARGETS datachannel LIBRARY DESTINATION lib)
+install(TARGETS datachannel EXPORT libdatachannel-config
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
install(FILES ${LIBDATACHANNEL_HEADERS} DESTINATION include/rtc)
if(NOT MSVC)
@@ -374,3 +367,8 @@ endif()
add_subdirectory(examples/copy-paste-capi)
endif()
+install(
+ EXPORT libdatachannel-config
+ NAMESPACE LibDatachannel::
+ DESTINATION share/cmake/libdatachannel
+)
diff --git a/src/impl/tcptransport.hpp b/src/impl/tcptransport.hpp
index f091fa2..8bcfbe7 100644
--- a/src/impl/tcptransport.hpp
+++ b/src/impl/tcptransport.hpp
@@ -29,7 +29,7 @@
#include <thread>
// Use the socket defines from libjuice
-#include "../deps/libjuice/src/socket.h"
+#include <juice/src/socket.h>
namespace rtc::impl {