forked from osmocom/wireshark
CMake: Compile and link flag updates.
Add /guard:cf and /Qspectre to the Visual C++ 2015 compile and link flags. Don't bother trying to pass -Wl,--as-needed or -pie to Visual C++. Remove some unneeded quotes. Change-Id: I4d89d61ce9dd579e7cfbcd49df6116810bfb0178 Reviewed-on: https://code.wireshark.org/review/25356 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
d672ee9372
commit
7e37a7db55
|
@ -338,20 +338,27 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
|||
/MP
|
||||
)
|
||||
|
||||
set(WS_LINK_FLAGS "/LARGEADDRESSAWARE /MANIFEST:NO /INCREMENTAL:NO /RELEASE")
|
||||
|
||||
if(MSVC12)
|
||||
# /Zo Enhanced debugging of optimised code for VS2013 Update 3 and beyond,
|
||||
# Assume all VS2013 builds are at least Update 3.
|
||||
# See http://msdn.microsoft.com/en-us/library/dn785163.aspx
|
||||
set(LOCAL_CFLAGS ${LOCAL_CFLAGS} "/Zo")
|
||||
set(LOCAL_CFLAGS ${LOCAL_CFLAGS} /Zo)
|
||||
elseif(MSVC14)
|
||||
# /Zo Enhanced debugging of optimised code
|
||||
# /utf-8 Set Source and Executable character sets to UTF-8
|
||||
# VS2015(MSVC14): On by default when /Zi or /Z7 used.
|
||||
set(LOCAL_CFLAGS ${LOCAL_CFLAGS} "/Zo" "/utf-8")
|
||||
# /guard:cf Control Flow Guard (compile and link).
|
||||
# See https://msdn.microsoft.com/en-us/library/windows/desktop/mt637065.aspx
|
||||
# /Qspectre Speculative execution attack mitigation
|
||||
# See https://blogs.msdn.microsoft.com/vcblog/2018/01/15/spectre-mitigations-in-msvc/
|
||||
set(LOCAL_CFLAGS ${LOCAL_CFLAGS} /Zo /utf-8 /guard:cf /Qspectre)
|
||||
set(WS_LINK_FLAGS "${WS_LINK_FLAGS} /guard:cf")
|
||||
endif()
|
||||
|
||||
if(ENABLE_CODE_ANALYSIS)
|
||||
set(LOCAL_CFLAGS ${LOCAL_CFLAGS} "/analyze:WX-")
|
||||
set(LOCAL_CFLAGS ${LOCAL_CFLAGS} /analyze:WX-)
|
||||
endif()
|
||||
|
||||
# Additional compiler warnings to be treated as "Level 3"
|
||||
|
@ -360,16 +367,14 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
|||
## 4189: local variable is initialized but not referenced
|
||||
# Disable warnings about about use of flexible array members:
|
||||
## 4200: nonstandard extension used : zero-sized array in struct/union
|
||||
set(WARNINGS_CFLAGS "/w34295 /w34189 /wd4200")
|
||||
set(WARNINGS_CFLAGS /w34295 /w34189 /wd4200)
|
||||
|
||||
set(WIRESHARK_COMMON_FLAGS
|
||||
${LOCAL_CFLAGS}
|
||||
${WARNINGS_CFLAGS}
|
||||
)
|
||||
|
||||
set(WS_LINK_FLAGS "/LARGEADDRESSAWARE /MANIFEST:NO /INCREMENTAL:NO /RELEASE")
|
||||
|
||||
else()
|
||||
else() # ! MSVC
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
if(APPLE)
|
||||
if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.0")
|
||||
|
@ -633,7 +638,25 @@ else()
|
|||
-DG_DISABLE_DEPRECATED
|
||||
-DG_DISABLE_SINGLE_INCLUDES
|
||||
)
|
||||
endif()
|
||||
|
||||
set(WIRESHARK_LD_FLAGS
|
||||
-Wl,--as-needed
|
||||
# -flto
|
||||
# -fwhopr
|
||||
# -fwhole-program
|
||||
)
|
||||
# CMAKE_POSITION_INDEPENDENT_CODE is only supported starting with CMake
|
||||
# 2.8.9. Do not add -pie automatically for older versions.
|
||||
#
|
||||
# XXX - are there other compilers that don't support -pie? It's
|
||||
# not as if the only platforms we support are Windows and Linux....
|
||||
#
|
||||
if(NOT CMAKE_VERSION VERSION_LESS "2.8.9")
|
||||
set(WIRESHARK_LD_FLAGS ${WIRESHARK_LD_FLAGS}
|
||||
-pie
|
||||
)
|
||||
endif()
|
||||
endif() # ! MSVC
|
||||
|
||||
set( C_FLAG_TESTS ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_C_ONLY_FLAGS} )
|
||||
set( CXX_FLAG_TESTS ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_CXX_ONLY_FLAGS} )
|
||||
|
@ -800,24 +823,6 @@ if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
|||
endif()
|
||||
endif()
|
||||
|
||||
set(WIRESHARK_LD_FLAGS
|
||||
-Wl,--as-needed
|
||||
# -flto
|
||||
# -fwhopr
|
||||
# -fwhole-program
|
||||
)
|
||||
# CMAKE_POSITION_INDEPENDENT_CODE is only supported starting with CMake
|
||||
# 2.8.9. Do not add -pie automatically for older versions.
|
||||
#
|
||||
# XXX - are there other compilers that don't support -pie? It's
|
||||
# not as if the only platforms we support are Windows and Linux....
|
||||
#
|
||||
if(NOT CMAKE_VERSION VERSION_LESS "2.8.9")
|
||||
set(WIRESHARK_LD_FLAGS ${WIRESHARK_LD_FLAGS}
|
||||
-pie
|
||||
)
|
||||
endif()
|
||||
|
||||
include(CheckCLinkerFlag)
|
||||
set(_C 0)
|
||||
# Sigh: Have to use THIS_FLAG instead of ${F} for some reason
|
||||
|
|
Loading…
Reference in New Issue