From 80deef30b04351ff2fedb2c75ada8625ce0fe9b1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 1 Jun 2015 08:04:46 +0200 Subject: [PATCH] additional clang warning for tautological comparisons. added to catch a /Wall VS warning in Travis builds. --- src/CMakeLists.txt | 27 ++++++++++++++++----------- src/main.c | 1 - 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70182005d..71651c1a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,26 +12,31 @@ include_directories (${LUA_INCLUDE_DIR}) include_directories (${BSON_INCLUDE_DIR}) include_directories (${INIPARSER_INCLUDE_DIR}) -IF(CMAKE_COMPILER_IS_GNUCC) - execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion - OUTPUT_VARIABLE GCC_VERSION) - if (GCC_VERSION VERSION_GREATER 4.9) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion") - endif() +IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DHAVE__BOOL") -elseif(MSVC) +ELSEIF(MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib") -ELSE(CMAKE_COMPILER_IS_GNUCC) - MESSAGE(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}") -ENDIF(CMAKE_COMPILER_IS_GNUCC) +ELSE() + MESSAGE(STATUS "unknown compiler ${CMAKE_C_COMPILER_ID}") +ENDIF() + +IF(CMAKE_COMPILER_IS_CLANG) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wtautological-compare -Weverything") + MESSAGE(STATUS "compiler is clang: ${CMAKE_C_COMPILER_ID}") +ELSEIF(CMAKE_COMPILER_IS_GCC) + EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion + OUTPUT_VARIABLE GCC_VERSION) + IF (GCC_VERSION VERSION_GREATER 4.9) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion") + ENDIF() +ENDIF(CMAKE_COMPILER_IS_CLANG) add_subdirectory(util) add_subdirectory(kernel) diff --git a/src/main.c b/src/main.c index 8b1c8d984..d6267e4ba 100644 --- a/src/main.c +++ b/src/main.c @@ -282,7 +282,6 @@ int main(int argc, char **argv) int err = 0; lua_State *L; setup_signal_handler(); - /* parse args once to read config file location */ if (parse_args(argc, argv, &err) != 0) { return err;