mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
cmake: fix adding of compiler flags, and now it will
- add_compiler_flags() must accept array IOW just ARGN will be enoough - add_compiler_flags() called with variable name instead of it's value P.S. and fix some alignments issues P.P.S. more cmake issues expected since now CFLAGS actually works P.P.P.S. some issues with cmake cache is possible, so just reset it
This commit is contained in:
parent
f29f59e811
commit
36588e169d
@ -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 <options> ..")
|
||||
message(FATAL_ERROR "Trying to compile coverage support, but compiler is not GNU gcc! Try CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..")
|
||||
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.
|
||||
|
@ -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()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user