瀏覽代碼

Added USE_SYSTEM_JSON cmake option

tytan652 2 年之前
父節點
當前提交
2dc3d77e07

+ 6 - 1
CMakeLists.txt

@@ -9,6 +9,7 @@ option(USE_GNUTLS "Use GnuTLS instead of OpenSSL" OFF)
 option(USE_NICE "Use libnice instead of libjuice" OFF)
 option(USE_SYSTEM_SRTP "Use system libSRTP" OFF)
 option(USE_SYSTEM_JUICE "Use system libjuice" OFF)
+option(USE_SYSTEM_JSON "Use system Nlohmann JSON" OFF)
 option(NO_WEBSOCKET "Disable WebSocket support" OFF)
 option(NO_MEDIA "Disable media transport support" OFF)
 option(NO_EXAMPLES "Disable examples" OFF)
@@ -473,7 +474,11 @@ endif()
 # Examples
 if(NOT NO_EXAMPLES)
 	set(JSON_BuildTests OFF CACHE INTERNAL "")
-	add_subdirectory(deps/json EXCLUDE_FROM_ALL)
+	if(USE_SYSTEM_JSON)
+		find_package(nlohmann_json REQUIRED)
+	else()
+		add_subdirectory(deps/json EXCLUDE_FROM_ALL)
+	endif()
 
 	if(NOT NO_WEBSOCKET)
 		add_subdirectory(examples/client)

+ 1 - 1
examples/client-benchmark/CMakeLists.txt

@@ -29,7 +29,7 @@ set_target_properties(datachannel-client-benchmark PROPERTIES
 	XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.github.paullouisageneau.libdatachannel.examples.client.benchmark)
 
 find_package(Threads REQUIRED)
-target_link_libraries(datachannel-client-benchmark LibDataChannel::LibDataChannel Threads::Threads nlohmann_json)
+target_link_libraries(datachannel-client-benchmark LibDataChannel::LibDataChannel Threads::Threads nlohmann_json::nlohmann_json)
 
 if(MSVC)
 	add_custom_command(TARGET datachannel-client-benchmark POST_BUILD

+ 1 - 1
examples/client/CMakeLists.txt

@@ -43,7 +43,7 @@ set_target_properties(datachannel-client PROPERTIES
 	XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.github.paullouisageneau.libdatachannel.examples.client)
 
 find_package(Threads REQUIRED)
-target_link_libraries(datachannel-client LibDataChannel::LibDataChannel Threads::Threads nlohmann_json)
+target_link_libraries(datachannel-client LibDataChannel::LibDataChannel Threads::Threads nlohmann_json::nlohmann_json)
 
 if(MSVC)
 	add_custom_command(TARGET datachannel-client POST_BUILD

+ 1 - 1
examples/media-receiver/CMakeLists.txt

@@ -24,7 +24,7 @@ set_target_properties(datachannel-media-receiver PROPERTIES
 	XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.github.paullouisageneau.libdatachannel.examples.media-receiver)
 
 find_package(Threads REQUIRED)
-target_link_libraries(datachannel-media-receiver LibDataChannel::LibDataChannel Threads::Threads nlohmann_json)
+target_link_libraries(datachannel-media-receiver LibDataChannel::LibDataChannel Threads::Threads nlohmann_json::nlohmann_json)
 
 if(MSVC)
 	add_custom_command(TARGET datachannel-media-receiver POST_BUILD

+ 1 - 1
examples/media-sender/CMakeLists.txt

@@ -24,7 +24,7 @@ set_target_properties(datachannel-media-sender PROPERTIES
 	XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.github.paullouisageneau.libdatachannel.examples.media-sender)
 
 find_package(Threads REQUIRED)
-target_link_libraries(datachannel-media-sender LibDataChannel::LibDataChannel Threads::Threads nlohmann_json)
+target_link_libraries(datachannel-media-sender LibDataChannel::LibDataChannel Threads::Threads nlohmann_json::nlohmann_json)
 
 if(MSVC)
 	add_custom_command(TARGET datachannel-media-sender POST_BUILD

+ 1 - 1
examples/media-sfu/CMakeLists.txt

@@ -23,7 +23,7 @@ set_target_properties(datachannel-media-sfu PROPERTIES
 set_target_properties(datachannel-media-sfu PROPERTIES
 	XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.github.paullouisageneau.libdatachannel.examples.sfumedia)
 
-target_link_libraries(datachannel-media-sfu LibDataChannel::LibDataChannel nlohmann_json)
+target_link_libraries(datachannel-media-sfu LibDataChannel::LibDataChannel nlohmann_json::nlohmann_json)
 
 if(MSVC)
 	add_custom_command(TARGET datachannel-media-sfu POST_BUILD

+ 1 - 1
examples/streamer/CMakeLists.txt

@@ -45,7 +45,7 @@ set_target_properties(streamer PROPERTIES
 	XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.github.paullouisageneau.libdatachannel.examples.streamer)
 
 find_package(Threads REQUIRED)
-target_link_libraries(streamer LibDataChannel::LibDataChannel Threads::Threads nlohmann_json)
+target_link_libraries(streamer LibDataChannel::LibDataChannel Threads::Threads nlohmann_json::nlohmann_json)
 
 if(MSVC)
 	add_custom_command(TARGET streamer POST_BUILD