Skip to content

Commit

Permalink
Cmake : remove Wno-sign-compare, so we warn on sign diffences
Browse files Browse the repository at this point in the history
Don't ignore warnings that can cause problems.
However, since random versions of flex on different archirectures does
do this - turn this specific warnings off for those files.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed May 4, 2020
1 parent 3a202a5 commit 15bba24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ if (NOT LOG_LEVEL)
endif()

if (MSVC)
add_compile_options(/W4 /wd4018 /wd4200 /wd4127 /wd4100)
# C4018: signed/unsigned mismatch ; same as -Wno-sign-compare
add_compile_options(/W4 /wd4200 /wd4127 /wd4100)
# C4200: nonstandard extension used : zero-sized array in struct (usb.h)
# C4127: conditional expression is constant (IIO_ERROR and IIO_DEBUG macros)
# C4100: unreferenced parameter; same as -Wno-unused-parameter
Expand All @@ -77,7 +76,7 @@ elseif (CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter")

include(CheckCCompilerFlag)
check_c_compiler_flag(-Wpedantic HAS_WPEDANTIC)
Expand All @@ -97,7 +96,7 @@ elseif (CMAKE_COMPILER_IS_GNUCC)
endif()

elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-sign-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter")
if(DEFINED ENV{TRAVIS} AND DEFINED ENV{CI})
message(STATUS "Running in a Travis-CI environment, setting -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
Expand Down
6 changes: 6 additions & 0 deletions iiod/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ add_flex_bison_dependency(lexer parser)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

if (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCC)
# flex sometimes generates code which generate sign comparison errors
set_source_files_properties(${FLEX_lexer_OUTPUTS} PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
set_source_files_properties(${BISON_parser_OUTPUTS} PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
endif ()

set(IIOD_CFILES iiod.c ops.c thread-pool.c ${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS})

find_library(LIBAIO_LIBRARIES aio)
Expand Down

0 comments on commit 15bba24

Please sign in to comment.