mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 20:50:25 +08:00
VS with hardening: added guard flag, moved dynamicbase and safeseh to linker flags
This commit is contained in:
parent
7a472d85ef
commit
74367093c8
@ -37,9 +37,13 @@ endmacro()
|
||||
|
||||
if(MSVC)
|
||||
ocv_add_defense_compiler_flag("/GS")
|
||||
ocv_add_defense_compiler_flag("/DynamicBase")
|
||||
ocv_add_defense_compiler_flag("/SafeSEH")
|
||||
ocv_add_defense_compiler_flag("/sdl")
|
||||
ocv_add_defense_compiler_flag("/guard:cf")
|
||||
ocv_add_defense_compiler_flag("/w34018 /w34146 /w34244 /w34267 /w34302 /w34308 /w34509 /w34532 /w34533 /w34700 /w34789 /w34995 /w34996")
|
||||
set(OPENCV_LINKER_DEFENSES_FLAGS_COMMON "${OPENCV_LINKER_DEFENSES_FLAGS_COMMON} /guard:cf /dynamicbase" )
|
||||
if(NOT X86_64)
|
||||
set(OPENCV_LINKER_DEFENSES_FLAGS_COMMON "${OPENCV_LINKER_DEFENSES_FLAGS_COMMON} /safeseh")
|
||||
endif()
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
|
||||
ocv_add_defense_compiler_flag("-fstack-protector")
|
||||
@ -67,10 +71,10 @@ else()
|
||||
endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
if(NOT CMAKE_CXX_FLAGS MATCHES "-fPIC")
|
||||
ocv_add_defense_compiler_flag("-fPIC")
|
||||
endif()
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(NOT CMAKE_CXX_FLAGS MATCHES "-fPIC")
|
||||
ocv_add_defense_compiler_flag("-fPIC")
|
||||
endif()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user