cxx_warnings: Misc changes to enable Werror

* CMake option to enable -Werror as default
    * Change to make sure all cxx examples have correct target name
    * Added PUBLIC CXX compiler flags to ads1x15 and ozw targets to
      work around compiler warnings
    * Renamed cmake variable for compiler warnings

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2016-11-03 16:10:35 -07:00
parent 601d25cebc
commit 9be920dbcd
6 changed files with 66 additions and 51 deletions

View File

@ -1,3 +1,7 @@
# Selectively disable certain warnings for the examples
# nrf examples flag -Wtautological-compare
set (CXX_DISABLED_WARNINGS -Wno-tautological-compare)
# Extract module name from non-standard example name
macro(get_module_name example_name module_name)
string(LENGTH ${example_name} length)
@ -32,6 +36,15 @@ macro(add_custom_example example_bin example_src example_module_list)
if (found_all_modules)
add_executable (${example_bin} ${example_src})
target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
# Disable warnings from CXX_DISABLED_WARNINGS
foreach(flag ${CXX_DISABLED_WARNINGS})
compiler_flag_supported(CXX is_supported ${flag})
if (is_supported)
target_compile_options(${example_bin} PRIVATE "${flag}")
endif(is_supported)
endforeach(flag ${CXX_DISABLED_WARNINGS})
foreach (module ${example_module_list})
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}")
include_directories (${module_dir})
@ -55,11 +68,6 @@ macro(add_example example_name)
get_module_name(${example_name} module_name)
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
# nrf examples can flag a warning, make sure this isn't an error, currently
# this is done for all examples
set_source_files_properties(${example_src}
PROPERTIES COMPILE_FLAGS -Wno-tautological-compare)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}"
AND EXISTS ${module_dir}
AND IS_DIRECTORY ${module_dir})
@ -316,42 +324,42 @@ add_example (sht1x)
# These are special cases where you specify example binary, source file and module(s)
include_directories (${PROJECT_SOURCE_DIR}/src)
add_custom_example (groveled-multi-example groveled-multi.cxx grove)
add_custom_example (lcm1602-i2c-example lcm1602-i2c.cxx lcd)
add_custom_example (lcm1602-parallel-example lcm1602-parallel.cxx lcd)
add_custom_example (jhd1313m1-lcd-example jhd1313m1-lcd.cxx lcd)
add_custom_example (es08a-example es08a.cxx servo)
add_custom_example (ssd1306-oled-example ssd1306-oled.cxx lcd)
add_custom_example (ssd1308-oled-example ssd1308-oled.cxx lcd)
add_custom_example (ssd1327-oled-example ssd1327-oled.cxx lcd)
add_custom_example (sainsmartks-example sainsmartks.cxx lcd)
add_custom_example (eboled-example eboled.cxx lcd)
add_custom_example (mpu60x0-example mpu60x0.cxx mpu9150)
add_custom_example (ak8975-example ak8975.cxx mpu9150)
add_custom_example (mpu9250-example mpu9250.cxx mpu9150)
add_custom_example (groveledbar-example groveledbar.cxx my9221)
add_custom_example (grovecircularled-example grovecircularled.cxx my9221)
add_custom_example (temperature-sensor-example temperature-sensor.cxx "si7005;bmpx8x;bmp280")
add_custom_example (humidity-sensor-example humidity-sensor.cxx "si7005;bmp280")
add_custom_example (pressure-sensor-example pressure-sensor.cxx "bmpx8x;bmp280")
add_custom_example (co2-sensor-example co2-sensor.cxx "t6713")
add_custom_example (adc-example adc-sensor.cxx "ads1x15")
add_custom_example (light-sensor-example light-sensor.cxx "si1132;max44009")
add_custom_example (light-controller-example light-controller.cxx "lp8860;ds1808lc;hlg150h")
add_custom_example (bme280-example bme280.cxx bmp280)
add_custom_example (bma250e-example bma250e.cxx bmx055)
add_custom_example (bmg160-example bmg160.cxx bmx055)
add_custom_example (bmm150-example bmm150.cxx bmx055)
add_custom_example (bmc150-example bmc150.cxx bmx055)
add_custom_example (bmi055-example bmi055.cxx bmx055)
add_custom_example (groveled-multi-example-cxx groveled-multi.cxx grove)
add_custom_example (lcm1602-i2c-example-cxx lcm1602-i2c.cxx lcd)
add_custom_example (lcm1602-parallel-example-cxx lcm1602-parallel.cxx lcd)
add_custom_example (jhd1313m1-lcd-example-cxx jhd1313m1-lcd.cxx lcd)
add_custom_example (es08a-example-cxx es08a.cxx servo)
add_custom_example (ssd1306-oled-example-cxx ssd1306-oled.cxx lcd)
add_custom_example (ssd1308-oled-example-cxx ssd1308-oled.cxx lcd)
add_custom_example (ssd1327-oled-example-cxx ssd1327-oled.cxx lcd)
add_custom_example (sainsmartks-example-cxx sainsmartks.cxx lcd)
add_custom_example (eboled-example-cxx eboled.cxx lcd)
add_custom_example (mpu60x0-example-cxx mpu60x0.cxx mpu9150)
add_custom_example (ak8975-example-cxx ak8975.cxx mpu9150)
add_custom_example (mpu9250-example-cxx mpu9250.cxx mpu9150)
add_custom_example (groveledbar-example-cxx groveledbar.cxx my9221)
add_custom_example (grovecircularled-example-cxx grovecircularled.cxx my9221)
add_custom_example (temperature-sensor-example-cxx temperature-sensor.cxx "si7005;bmpx8x;bmp280")
add_custom_example (humidity-sensor-example-cxx humidity-sensor.cxx "si7005;bmp280")
add_custom_example (pressure-sensor-example-cxx pressure-sensor.cxx "bmpx8x;bmp280")
add_custom_example (co2-sensor-example-cxx co2-sensor.cxx "t6713")
add_custom_example (adc-example-cxx adc-sensor.cxx "ads1x15")
add_custom_example (light-sensor-example-cxx light-sensor.cxx "si1132;max44009")
add_custom_example (light-controller-example-cxx light-controller.cxx "lp8860;ds1808lc;hlg150h")
add_custom_example (bme280-example-cxx bme280.cxx bmp280)
add_custom_example (bma250e-example-cxx bma250e.cxx bmx055)
add_custom_example (bmg160-example-cxx bmg160.cxx bmx055)
add_custom_example (bmm150-example-cxx bmm150.cxx bmx055)
add_custom_example (bmc150-example-cxx bmc150.cxx bmx055)
add_custom_example (bmi055-example-cxx bmi055.cxx bmx055)
if (OPENZWAVE_FOUND)
include_directories(${OPENZWAVE_INCLUDE_DIRS})
add_custom_example (ozwdump-example ozwdump.cxx ozw)
add_custom_example (aeotecss6-example aeotecss6.cxx ozw)
add_custom_example (aeotecsdg2-example aeotecsdg2.cxx ozw)
add_custom_example (aeotecdw2e-example aeotecdw2e.cxx ozw)
add_custom_example (aeotecdsb09104-example aeotecdsb09104.cxx ozw)
add_custom_example (tzemt400-example tzemt400.cxx ozw)
add_custom_example (ozwdump-example-cxx ozwdump.cxx ozw)
add_custom_example (aeotecss6-example-cxx aeotecss6.cxx ozw)
add_custom_example (aeotecsdg2-example-cxx aeotecsdg2.cxx ozw)
add_custom_example (aeotecdw2e-example-cxx aeotecdw2e.cxx ozw)
add_custom_example (aeotecdsb09104-example-cxx aeotecdsb09104.cxx ozw)
add_custom_example (tzemt400-example-cxx tzemt400.cxx ozw)
endif()
add_custom_example (nmea_gps_i2c_example-cxx nmea_gps_i2c.cxx nmea_gps)