diff --git a/CMakeLists.txt b/CMakeLists.txt index 53ec8c5f..6b6ae2ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,7 +145,7 @@ endif() # Setup compiler flags for coverage. if (EVENT__COVERAGE) if ((NOT CMAKE_COMPILER_IS_GNUCC) AND (NOT ${CMAKE_CXX_COMPILER_ID} STREQAL "Clang")) - message(FATAL_ERROR"Trying to compile coverage support, but compiler is not GNU gcc! Try CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") + message(FATAL_ERROR "Trying to compile coverage support, but compiler is not GNU gcc! Try CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") endif() if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -153,7 +153,7 @@ if (EVENT__COVERAGE) endif() message(STATUS "Setting coverage compiler flags") - add_compiler_flags(-g -O0 -fprofile-arcs -ftest-coverage) + add_compiler_flags(-g -O0 -fprofile-arcs -ftest-coverage) endif() # GCC specific options. @@ -163,44 +163,45 @@ if (CMAKE_COMPILER_IS_GNUCC) option(EVENT__ENABLE_GCC_FUNCTION_SECTIONS "Enable gcc function sections" OFF) option(EVENT__ENABLE_GCC_WARNINGS "Make all GCC warnings into errors" OFF) - list(APPEND __FLAGS -Wall -Wswitch) + list(APPEND __FLAGS -Wall -Wswitch) if (EVENT__DISABLE_GCC_WARNINGS) - list(APPEND __FLAGS -w) + list(APPEND __FLAGS -w) endif() if (EVENT__ENABLE_GCC_HARDENING) - list(APPEND __FLAGS - -fstack-protector-all - -fwrapv - -fPIE - -Wstack-protector - "--param ssp-buffer-size=1") + list(APPEND __FLAGS + -fstack-protector-all + -fwrapv + -fPIE + -Wstack-protector + "--param ssp-buffer-size=1") - add_definitions(-D_FORTIFY_SOURCE=2) + add_definitions(-D_FORTIFY_SOURCE=2) endif() if (EVENT__ENABLE_GCC_FUNCTION_SECTIONS) - list(APPEND __FLAGS -ffunction-sections) + list(APPEND __FLAGS -ffunction-sections) # TODO: Add --gc-sections support. We need some checks for NetBSD to ensure this works. endif() if (EVENT__ENABLE_GCC_WARNINGS) - list(APPEND __FLAGS -Werror) + list(APPEND __FLAGS -Werror) endif() # We need to test for at least gcc 2.95 here, because older versions don't # have -fno-strict-aliasing - list(APPEND __FLAGS -fno-strict-aliasing) + list(APPEND __FLAGS -fno-strict-aliasing) - add_compiler_flags(__FLAGS) + add_compiler_flags(${__FLAGS}) endif() if (APPLE) # Get rid of deprecated warnings for OpenSSL on OSX 10.7 and greater. - add_compiler_flags( - -Wno-error=deprecated-declarations - -Qunused-arguments) + add_compiler_flags( + -Wno-error=deprecated-declarations + -Qunused-arguments + ) endif() # Winsock. diff --git a/cmake/AddCompilerFlags.cmake b/cmake/AddCompilerFlags.cmake index c7da188b..9dc21d03 100644 --- a/cmake/AddCompilerFlags.cmake +++ b/cmake/AddCompilerFlags.cmake @@ -1,7 +1,7 @@ include(CheckCCompilerFlag) -macro(add_compiler_flags _flags) - foreach(flag ${_flags}) +macro(add_compiler_flags) + foreach(flag ${ARGN}) string(REGEX REPLACE "[-.+/:= ]" "_" _flag_esc "${flag}") check_c_compiler_flag("${flag}" check_c_compiler_flag_${_flag_esc}) @@ -11,5 +11,3 @@ macro(add_compiler_flags _flags) endif() endforeach() endmacro() - -