Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 21e45e2

Browse files
committed
Add a CMake option to not turn warnings into errors
We have some warnings in Release configuration because of: - unused arguments (some calls to `assert`, that are completly removed in release mode, cause some arguments to be unused) in such a pattern: void f(bool b) { assert(b); } - strict aliasing rules violation in floating point tests. Since this is only test code, it is not considered critical. Add an option (on by default) to add the -Werror flag. Have travis travis build the Parameter Framework in "Release" configuration (it previously built in "Debug" and "None" configurations) without the -Werror flag. Also, forcefully remove the "/WX" flag on windows (equivalent to -Werror) because we are not warning-free yet, even in debug mode. Signed-off-by: David Wagner <[email protected]>
1 parent be72739 commit 21e45e2

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ script:
5757
make -j &&
5858
CTEST_OUTPUT_ON_FAILURE=1 make ExperimentalTest ExperimentalMemCheck )
5959
- ( mkdir build && cd build &&
60-
cmake -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_INSTALL_PREFIX=../install .. &&
60+
cmake -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Release .. &&
6161
make -j &&
6262
CTEST_OUTPUT_ON_FAILURE=1 make test &&
6363
make install &&
6464
cpack --verbose -G DEB && dpkg --info *.deb)
6565
- ( cd skeleton-subsystem &&
66-
cmake -DCMAKE_INSTALL_PREFIX=../install . &&
66+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install . &&
6767
make &&
6868
CTEST_OUTPUT_ON_FAILURE=1 make ExperimentalTest ExperimentalMemCheck &&
6969
make install )

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ option(DOXYGEN "Enable doxygen generation (you still have to run 'make doc')" OF
4242
option(REQUIREMENTS "Generate the html version of the 'requirements' documentation" OFF)
4343
option(PYTHON_BINDINGS "Python library to use the Parameter Framework from python" ON)
4444
option(C_BINDINGS "Library to use the Parameter Framework using a C API" ON)
45-
45+
option(FATAL_WARNINGS "Turn warnings into errors (-Werror flag)" ON)
4646

4747
# find and set the Parameter Framework's version
4848
execute_process(COMMAND git describe --tags --dirty
@@ -73,8 +73,14 @@ if(WIN32)
7373
# only public methods instead of the whole class, but they are too many to
7474
# do that. A separated plugin interface would fix that.
7575
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /FIiso646.h -wd4127 -wd4251")
76+
77+
# FIXME: Once we have removed all warnings on windows, add the /WX flags if
78+
# FATAL_WARNINGS is enabled
7679
else()
77-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -Wconversion -Wno-sign-conversion")
80+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wconversion -Wno-sign-conversion")
81+
if(FATAL_WARNINGS)
82+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
83+
endif()
7884
endif()
7985

8086
# Hide symbols by default, then exposed symbols are the same in linux and windows

bindings/python/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED)
5050
include_directories(${PYTHON_INCLUDE_DIRS})
5151

5252
set_property(SOURCE pfw.i PROPERTY CPLUSPLUS ON)
53-
set_property(SOURCE pfw.i PROPERTY SWIG_FLAGS "-Wall" "-Werror")
53+
set_property(SOURCE pfw.i PROPERTY SWIG_FLAGS "-Wall")
54+
if(FATAL_WARNINGS)
55+
set_property(SOURCE pfw.i APPEND PROPERTY SWIG_FLAGS "-Werror")
56+
endif()
5457

5558
swig_add_module(PyPfw python pfw.i)
5659
swig_link_libraries(PyPfw parameter ${PYTHON_LIBRARIES})
@@ -70,7 +73,8 @@ set_property(TARGET _PyPfw PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BIN
7073
# spurious anyway, as it relates to "ILogger *" which is an abstract
7174
# class/interface class and as such cannot be destroyed.
7275
# -Wno-error is set to prevent compilation failure in case of the code
73-
# generated by swig generates warnings
76+
# generated by swig generates warnings. We don't apply the FATAL_WARNING policy
77+
# here, since we consider this generated code as external.
7478
target_compile_definitions(_PyPfw PRIVATE SWIG_PYTHON_SILENT_MEMLEAK)
7579
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error")
7680

0 commit comments

Comments
 (0)