diff --git a/.github/workflows/build-gnutls.yml b/.github/workflows/build-gnutls.yml index 6f07954..320adb6 100644 --- a/.github/workflows/build-gnutls.yml +++ b/.github/workflows/build-gnutls.yml @@ -16,7 +16,7 @@ jobs: - name: submodules run: git submodule update --init --recursive - name: cmake - run: cmake -B build -DUSE_JUICE=1 -DUSE_GNUTLS=1 + run: cmake -B build -DUSE_GNUTLS=1 - name: make run: (cd build; make -j2) - name: test @@ -30,7 +30,7 @@ jobs: - name: submodules run: git submodule update --init --recursive - name: cmake - run: cmake -B build -DUSE_JUICE=1 -DUSE_GNUTLS=1 + run: cmake -B build -DUSE_GNUTLS=1 - name: make run: (cd build; make -j2) - name: test diff --git a/.github/workflows/build-nice.yml b/.github/workflows/build-nice.yml index 1f88da9..2b3cda1 100644 --- a/.github/workflows/build-nice.yml +++ b/.github/workflows/build-nice.yml @@ -16,7 +16,7 @@ jobs: - name: submodules run: git submodule update --init --recursive - name: cmake - run: cmake -B build -DUSE_JUICE=0 -DUSE_GNUTLS=1 + run: cmake -B build -DUSE_GNUTLS=1 -DUSE_NICE=1 - name: make run: (cd build; make -j2) - name: test diff --git a/.github/workflows/build-openssl.yml b/.github/workflows/build-openssl.yml index aec7b13..db98875 100644 --- a/.github/workflows/build-openssl.yml +++ b/.github/workflows/build-openssl.yml @@ -16,7 +16,7 @@ jobs: - name: submodules run: git submodule update --init --recursive - name: cmake - run: cmake -B build -DUSE_JUICE=1 -DUSE_GNUTLS=0 + run: cmake -B build -DUSE_GNUTLS=0 - name: make run: (cd build; make -j2) - name: test @@ -30,7 +30,7 @@ jobs: - name: submodules run: git submodule update --init --recursive - name: cmake - run: cmake -B build -DUSE_JUICE=1 -DUSE_GNUTLS=0 + run: cmake -B build -DUSE_GNUTLS=0 env: OPENSSL_ROOT_DIR: /usr/local/opt/openssl OPENSSL_LIBRARIES: /usr/local/opt/openssl/lib @@ -48,7 +48,7 @@ jobs: - name: submodules run: git submodule update --init --recursive - name: cmake - run: cmake -B build -G "NMake Makefiles" -DUSE_JUICE=1 -DUSE_GNUTLS=0 + run: cmake -B build -G "NMake Makefiles" -DUSE_GNUTLS=0 - name: nmake run: | cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index b907b18..630065e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,19 @@ project(libdatachannel VERSION 0.6.5 LANGUAGES CXX) +# Options option(USE_GNUTLS "Use GnuTLS instead of OpenSSL" OFF) -option(USE_JUICE "Use libjuice instead of libnice" OFF) +option(USE_NICE "Use libnice instead of libjuice" OFF) option(USE_SRTP "Enable SRTP for media support" OFF) option(NO_WEBSOCKET "Disable WebSocket support" OFF) option(NO_EXAMPLES "Disable examples" OFF) +if(USE_NICE) + option(USE_JUICE "Use libjuice" OFF) +else() + option(USE_JUICE "Use libjuice" ON) +endif() + if(USE_GNUTLS) option(USE_NETTLE "Use Nettle instead of OpenSSL in libjuice" ON) else() @@ -185,18 +192,18 @@ else() target_link_libraries(datachannel-static PRIVATE OpenSSL::SSL) endif() -if (USE_JUICE) - add_subdirectory(deps/libjuice EXCLUDE_FROM_ALL) - target_compile_definitions(datachannel PRIVATE USE_JUICE=1) - target_compile_definitions(datachannel-static PRIVATE USE_JUICE=1) - target_link_libraries(datachannel PRIVATE LibJuice::LibJuiceStatic) - target_link_libraries(datachannel-static PRIVATE LibJuice::LibJuiceStatic) -else() +if (USE_NICE OR NOT USE_JUICE) find_package(LibNice REQUIRED) target_compile_definitions(datachannel PRIVATE USE_JUICE=0) target_compile_definitions(datachannel-static PRIVATE USE_JUICE=0) target_link_libraries(datachannel PRIVATE LibNice::LibNice) target_link_libraries(datachannel-static PRIVATE LibNice::LibNice) +else() + add_subdirectory(deps/libjuice EXCLUDE_FROM_ALL) + target_compile_definitions(datachannel PRIVATE USE_JUICE=1) + target_compile_definitions(datachannel-static PRIVATE USE_JUICE=1) + target_link_libraries(datachannel PRIVATE LibJuice::LibJuiceStatic) + target_link_libraries(datachannel-static PRIVATE LibJuice::LibJuiceStatic) endif() add_library(LibDataChannel::LibDataChannel ALIAS datachannel) diff --git a/Jamfile b/Jamfile index da4a999..904065d 100644 --- a/Jamfile +++ b/Jamfile @@ -15,7 +15,7 @@ lib libdatachannel : # requirements 17 ./include/rtc - USE_JUICE=1 + USE_NICE=0 RTC_ENABLE_MEDIA=0 RTC_ENABLE_WEBSOCKET=0 msvc:WIN32_LEAN_AND_MEAN diff --git a/Makefile b/Makefile index 1d009a1..b5633f7 100644 --- a/Makefile +++ b/Makefile @@ -25,17 +25,17 @@ else LIBS+=openssl endif -USE_JUICE ?= 0 -ifneq ($(USE_JUICE), 0) +USE_NICE ?= 0 +ifneq ($(USE_NICE), 0) + CPPFLAGS+=-DUSE_JUICE=0 + LIBS+=glib-2.0 gobject-2.0 nice +else CPPFLAGS+=-DUSE_JUICE=1 INCLUDES+=-I$(JUICE_DIR)/include LOCALLIBS+=libjuice.a ifneq ($(USE_GNUTLS), 0) LIBS+=nettle endif -else - CPPFLAGS+=-DUSE_JUICE=0 - LIBS+=glib-2.0 gobject-2.0 nice endif USE_SRTP ?= 0 diff --git a/README.md b/README.md index 0072a1d..ec893c1 100644 --- a/README.md +++ b/README.md @@ -47,14 +47,14 @@ Features: Dependencies: - GnuTLS: https://www.gnutls.org/ or OpenSSL: https://www.openssl.org/ -Optional dependencies: -- libnice: https://nice.freedesktop.org/ (substituable with libjuice) -- libSRTP: https://github.com/cisco/libsrtp (only necessary for media transport) - Submodules: - libjuice: https://github.com/paullouisageneau/libjuice - usrsctp: https://github.com/sctplab/usrsctp +Optional dependencies: +- libnice: https://nice.freedesktop.org/ (only if selected as ICE backend instead of libjuice) +- libSRTP: https://github.com/cisco/libsrtp (only necessary for media transport) + ## Building ### Clone repository and submodules @@ -67,33 +67,35 @@ $ git submodule update --init --recursive ### Building with CMake -The CMake library targets `libdatachannel` and `libdatachannel-static` respectively correspond to the shared and static libraries. On Windows, the DLL resulting from the shared library build only exposes the C API, use the static library for the C++ API. The default target will build tests and examples. +The CMake library targets `libdatachannel` and `libdatachannel-static` respectively correspond to the shared and static libraries. On Windows, the DLL resulting from the shared library build only exposes the C API, use the static library for the C++ API. The default target will build tests and examples. The option `USE_GNUTLS` allows to switch between OpenSSL (default) and GnuTLS, and the option `USE_NICE` allows to switch between libjuice as submodule (default) and libnice. #### POSIX-compliant operating systems (including Linux and Apple macOS) ```bash -$ cmake -B build -DUSE_JUICE=1 -DUSE_GNUTLS=1 +$ cmake -B build -DUSE_GNUTLS=1 -DUSE_NICE=0 $ cd build $ make -j2 ``` #### Microsoft Windows with MinGW cross-compilation ```bash -$ cmake -B build -DUSE_JUICE=1 -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-x86_64-w64-mingw32.cmake # replace with your toolchain file +$ cmake -B build -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-x86_64-w64-mingw32.cmake # replace with your toolchain file $ cd build $ make -j2 ``` #### Microsoft Windows with Microsoft Visual C++ ```bash -$ cmake -B build -G "NMake Makefiles" -DUSE_JUICE=1 +$ cmake -B build -G "NMake Makefiles" $ cd build $ nmake ``` ### Building directly with Make (Linux only) +The option `USE_GNUTLS` allows to switch between OpenSSL (default) and GnuTLS, and the option `USE_NICE` allows to switch between libjuice as submodule (default) and libnice. + ```bash -$ make USE_JUICE=1 USE_GNUTLS=1 +$ make USE_GNUTLS=1 USE_NICE=0 ``` ## Examples