@ -480,18 +480,21 @@ if(ENABLE_HARDENING)
try_append_linker_flag ( "/HIGHENTROPYVA" TARGET hardening_interface )
try_append_linker_flag ( "/NXCOMPAT" TARGET hardening_interface )
else ( )
# _ F O R T I F Y _ S O U R C E r e q u i r e s t h a t t h e r e i s s o m e l e v e l o f o p t i m i z a t i o n ,
# o t h e r w i s e i t d o e s n o t h i n g a n d j u s t c r e a t e s a c o m p i l e r w a r n i n g .
try_append_cxx_flags ( "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
R E S U L T _ V A R c x x _ s u p p o r t s _ f o r t i f y _ s o u r c e
S O U R C E " i n t main ( ) {
# i f ! d e f i n e d _ _ O P T I M I Z E _ _ | | _ _ O P T I M I Z E _ _ < = 0
# e r r o r
# e n d i f
} "
)
if ( cxx_supports_fortify_source )
# W h e n t h e b u i l d c o n f i g u r a t i o n i s D e b u g , a l l o p t i m i z a t i o n s a r e d i s a b l e d .
# H o w e v e r , _ F O R T I F Y _ S O U R C E r e q u i r e s t h a t t h e r e i s s o m e l e v e l o f o p t i m i z a t i o n ,
# o t h e r w i s e i t d o e s n o t h i n g a n d j u s t c r e a t e s a c o m p i l e r w a r n i n g .
# S i n c e _ F O R T I F Y _ S O U R C E i s a n o - o p w i t h o u t o p t i m i z a t i o n s , d o n o t e n a b l e i t
# w h e n t h e b u i l d c o n f i g u r a t i o n i s D e b u g .
target_compile_options ( hardening_interface INTERFACE
$< $ < N O T : $ < C O N F I G : D e b u g > > : -U _ F O R T I F Y _ S O U R C E >
$< $ < N O T : $ < C O N F I G : D e b u g > > : -D _ F O R T I F Y _ S O U R C E = 3 >
- U _ F O R T I F Y _ S O U R C E
- D _ F O R T I F Y _ S O U R C E = 3
)
endif ( )
unset ( cxx_supports_fortify_source )