Treat warnings as errors in CI builds
The CMake files now add "-Werror"/"/WX" if the "WERROR" CMake variable is true. By default it is not; the CI builds set this. Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
32b683bf37
commit
f6fc1751e9
3 changed files with 29 additions and 11 deletions
|
@ -164,6 +164,7 @@ script:
|
||||||
-DCMAKE_INSTALL_PREFIX=$(pwd)/install
|
-DCMAKE_INSTALL_PREFIX=$(pwd)/install
|
||||||
-DUSE_SANITIZER=${ASAN}
|
-DUSE_SANITIZER=${ASAN}
|
||||||
-DBUILD_TESTING=on
|
-DBUILD_TESTING=on
|
||||||
|
-DWERROR=on
|
||||||
-G "${GENERATOR}" ../src
|
-G "${GENERATOR}" ../src
|
||||||
- ${SCAN_BUILD} cmake --build . --config ${BUILD_TYPE} --target install
|
- ${SCAN_BUILD} cmake --build . --config ${BUILD_TYPE} --target install
|
||||||
- CYCLONEDDS_URI='<CycloneDDS><DDSI2E><Internal><EnableExpensiveChecks>all</EnableExpensiveChecks></Internal></DDSI2E></CycloneDDS>' ctest -T test -C ${BUILD_TYPE}
|
- CYCLONEDDS_URI='<CycloneDDS><DDSI2E><Internal><EnableExpensiveChecks>all</EnableExpensiveChecks></Internal></DDSI2E></CycloneDDS>' ctest -T test -C ${BUILD_TYPE}
|
||||||
|
|
|
@ -36,7 +36,7 @@ build_script:
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- conan install -s arch=%ARCH% -s build_type=%CONFIGURATION% ..
|
- conan install -s arch=%ARCH% -s build_type=%CONFIGURATION% ..
|
||||||
- cmake -DBUILD_TESTING=on -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=%CD%/install -G "%GENERATOR%" ../src
|
- cmake -DBUILD_TESTING=on -DWERROR=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=%CD%/install -G "%GENERATOR%" ../src
|
||||||
- cmake --build . --config %CONFIGURATION% --target install -- /maxcpucount
|
- cmake --build . --config %CONFIGURATION% --target install -- /maxcpucount
|
||||||
- cd install/share/CycloneDDS/examples/helloworld
|
- cd install/share/CycloneDDS/examples/helloworld
|
||||||
- mkdir build
|
- mkdir build
|
||||||
|
|
|
@ -22,6 +22,11 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# By default don't treat warnings as errors, else anyone building it with a different compiler that
|
||||||
|
# just happens to generate a warning, as well as anyone adding or modifying something and making a
|
||||||
|
# small mistake would run into errors. CI builds can be configured differently.
|
||||||
|
option(WERROR "Treat compiler warnings as errors" OFF)
|
||||||
|
|
||||||
FUNCTION(PREPEND var prefix)
|
FUNCTION(PREPEND var prefix)
|
||||||
SET(listVar "")
|
SET(listVar "")
|
||||||
FOREACH(f ${ARGN})
|
FOREACH(f ${ARGN})
|
||||||
|
@ -86,18 +91,30 @@ endif()
|
||||||
|
|
||||||
# Set reasonably strict warning options for clang, gcc, msvc
|
# Set reasonably strict warning options for clang, gcc, msvc
|
||||||
# Enable coloured ouput if Ninja is used for building
|
# Enable coloured ouput if Ninja is used for building
|
||||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang")
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
||||||
add_definitions(-Wall -Wextra -Wconversion -Wunused -Wmissing-prototypes)
|
#message(STATUS clang)
|
||||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
add_compile_options(-Wall -Wextra -Wconversion -Wunused -Wmissing-prototypes)
|
||||||
add_definitions(-Xclang -fcolor-diagnostics)
|
if(${WERROR})
|
||||||
|
add_compile_options(-Werror)
|
||||||
endif()
|
endif()
|
||||||
elseif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
|
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
|
||||||
add_definitions(-Wall -Wextra -Wconversion -Wmissing-prototypes)
|
add_compile_options(-Xclang -fcolor-diagnostics)
|
||||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
endif()
|
||||||
add_definitions(-fdiagnostics-color=always)
|
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
#message(STATUS gcc)
|
||||||
|
add_compile_options(-Wall -Wextra -Wconversion -Wmissing-prototypes)
|
||||||
|
if(${WERROR})
|
||||||
|
add_compile_options(-Werror)
|
||||||
|
endif()
|
||||||
|
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
|
||||||
|
add_compile_options(-fdiagnostics-color=always)
|
||||||
|
endif()
|
||||||
|
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
|
#message(STATUS msvc)
|
||||||
|
add_compile_options(/W3)
|
||||||
|
if(${WERROR})
|
||||||
|
add_compile_options(/WX)
|
||||||
endif()
|
endif()
|
||||||
elseif(${CMAKE_C_COMPILER_ID} STREQUAL "MSVC")
|
|
||||||
add_definitions(/W3)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# I don't know how to enable warnings properly so that it ends up in Xcode projects as well
|
# I don't know how to enable warnings properly so that it ends up in Xcode projects as well
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue