Ver Fonte

Fixed build with NO_WEBSOCKET=1

Paul-Louis Ageneau há 4 anos atrás
pai
commit
17da44a526
2 ficheiros alterados com 23 adições e 13 exclusões
  1. 18 12
      CMakeLists.txt
  2. 5 1
      test/capi_websocketserver.cpp

+ 18 - 12
CMakeLists.txt

@@ -291,14 +291,16 @@ if (USE_GNUTLS)
 			IMPORTED_LINK_INTERFACE_LANGUAGES C
 			IMPORTED_LOCATION "${GNUTLS_LIBRARIES}")
 	endif()
+	target_compile_definitions(datachannel PRIVATE USE_GNUTLS=1)
+	target_compile_definitions(datachannel-static PRIVATE USE_GNUTLS=1)
+	target_link_libraries(datachannel PRIVATE GnuTLS::GnuTLS)
+	target_link_libraries(datachannel-static PRIVATE GnuTLS::GnuTLS)
 	if (NOT NO_WEBSOCKET)
-		# Needed for SHA1
+		# Needed for SHA1, it should be present as GnuTLS cryptography backend
 		find_package(Nettle REQUIRED)
+		target_link_libraries(datachannel PRIVATE Nettle::Nettle)
+		target_link_libraries(datachannel-static PRIVATE Nettle::Nettle)
 	endif()
-	target_compile_definitions(datachannel PRIVATE USE_GNUTLS=1)
-	target_compile_definitions(datachannel-static PRIVATE USE_GNUTLS=1)
-	target_link_libraries(datachannel PRIVATE GnuTLS::GnuTLS Nettle::Nettle)
-	target_link_libraries(datachannel-static PRIVATE GnuTLS::GnuTLS Nettle::Nettle)
 else()
 	if(APPLE)
 		# This is a bug in CMake that causes it to prefer the system version over
@@ -407,13 +409,17 @@ endif()
 if(NOT NO_EXAMPLES)
 	set(JSON_BuildTests OFF CACHE INTERNAL "")
 	add_subdirectory(deps/json EXCLUDE_FROM_ALL)
-	add_subdirectory(examples/client)
-	add_subdirectory(examples/client-benchmark)
-if(NOT NO_MEDIA)
-	add_subdirectory(examples/media)
-	add_subdirectory(examples/sfu-media)
-    add_subdirectory(examples/streamer)
-endif()
+	if(NOT NO_WEBSOCKET)
+		add_subdirectory(examples/client)
+		add_subdirectory(examples/client-benchmark)
+	endif()
+	if(NOT NO_MEDIA)
+		add_subdirectory(examples/media)
+		add_subdirectory(examples/sfu-media)
+	endif()
+	if(NOT NO_MEDIA AND NOT NO_WEBSOCKET)
+    	add_subdirectory(examples/streamer)
+	endif()
 	add_subdirectory(examples/copy-paste)
 	add_subdirectory(examples/copy-paste-capi)
 endif()

+ 5 - 1
test/capi_websocketserver.cpp

@@ -18,6 +18,8 @@
 
 #include <rtc/rtc.h>
 
+#if RTC_ENABLE_WEBSOCKET
+
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
@@ -118,7 +120,7 @@ int test_capi_websocketserver_main() {
 	if (wsserver < 0)
 		goto error;
 
-	if(rtcGetWebSocketServerPort(wsserver) != int(port)) {
+	if (rtcGetWebSocketServerPort(wsserver) != int(port)) {
 		fprintf(stderr, "rtcGetWebSocketServerPort failed\n");
 		goto error;
 	}
@@ -167,3 +169,5 @@ void test_capi_websocketserver() {
 	if (test_capi_websocketserver_main())
 		throw std::runtime_error("WebSocketServer test failed");
 }
+
+#endif