Added cmake flag for warnings as errors

This commit is contained in:
Paul-Louis Ageneau
2020-08-10 14:04:45 +02:00
parent 498e7246a0
commit b44f90b87f
4 changed files with 20 additions and 13 deletions

View File

@ -16,7 +16,7 @@ jobs:
- name: submodules
run: git submodule update --init --recursive
- name: cmake
run: cmake -B build -DUSE_GNUTLS=1
run: cmake -B build -DUSE_GNUTLS=1 -DWARNINGS_AS_ERRORS=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_GNUTLS=1
run: cmake -B build -DUSE_GNUTLS=1 -DWARNINGS_AS_ERRORS=1
- name: make
run: (cd build; make -j2)
- name: test

View File

@ -16,7 +16,7 @@ jobs:
- name: submodules
run: git submodule update --init --recursive
- name: cmake
run: cmake -B build -DUSE_GNUTLS=1 -DUSE_NICE=1
run: cmake -B build -DUSE_GNUTLS=1 -DUSE_NICE=1 -DWARNINGS_AS_ERRORS=1
- name: make
run: (cd build; make -j2)
- name: test

View File

@ -16,7 +16,7 @@ jobs:
- name: submodules
run: git submodule update --init --recursive
- name: cmake
run: cmake -B build -DUSE_GNUTLS=0
run: cmake -B build -DUSE_GNUTLS=0 -DWARNINGS_AS_ERRORS=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_GNUTLS=0
run: cmake -B build -DUSE_GNUTLS=0 -WARNINGS_AS_ERRORS=1
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_GNUTLS=0
run: cmake -B build -G "NMake Makefiles" -DUSE_GNUTLS=0 -WARNINGS_AS_ERRORS=1
- name: nmake
run: |
cd build

View File

@ -11,6 +11,7 @@ option(USE_SRTP "Enable SRTP for media support" OFF)
option(NO_WEBSOCKET "Disable WebSocket support" OFF)
option(NO_EXAMPLES "Disable examples" OFF)
option(NO_TESTS "Disable tests build" OFF)
option(WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
if(USE_NICE)
option(USE_JUICE "Use libjuice" OFF)
@ -214,13 +215,19 @@ add_library(LibDataChannel::LibDataChannelStatic ALIAS datachannel-static)
install(TARGETS datachannel LIBRARY DESTINATION lib)
install(FILES ${LIBDATACHANNEL_HEADERS} DESTINATION include/rtc)
# Warnings as errors
if(MSVC)
target_compile_options(datachannel PRIVATE /WX)
target_compile_options(datachannel-static PRIVATE /WX)
else()
target_compile_options(datachannel PRIVATE -Wall -Wextra -Werror)
target_compile_options(datachannel-static PRIVATE -Wall -Wextra -Werror)
if(NOT MSVC)
target_compile_options(datachannel PRIVATE -Wall -Wextra)
target_compile_options(datachannel-static PRIVATE -Wall -Wextra)
endif()
if(WARNINGS_AS_ERRORS)
if(MSVC)
target_compile_options(datachannel PRIVATE /WX)
target_compile_options(datachannel-static PRIVATE /WX)
else()
target_compile_options(datachannel PRIVATE -Werror)
target_compile_options(datachannel-static PRIVATE -Werror)
endif()
endif()
# Tests