2021-01-08 15:15:45 +00:00
|
|
|
# Compiler options with hardening flags
|
|
|
|
|
2021-08-23 20:30:39 +00:00
|
|
|
function(add_warnings_optimizations target_name)
|
|
|
|
if(MSVC)
|
|
|
|
target_compile_options(${target_name}
|
|
|
|
PRIVATE
|
|
|
|
/W4
|
|
|
|
/permissive-
|
|
|
|
$<$<CONFIG:RELEASE>:/O2 /Ob2>
|
|
|
|
$<$<CONFIG:MINSIZEREL>:/O1 /Ob1>
|
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:/Zi /O2 /Ob1>
|
|
|
|
$<$<CONFIG:DEBUG>:/Zi /Ob0 /Od /RTC1>
|
|
|
|
)
|
2024-01-16 19:19:06 +00:00
|
|
|
elseif(NOT CMAKE_COMPILER_IS_GNU<C++> AND
|
|
|
|
"${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
|
|
|
|
# clang on Android, no prof/gprof
|
|
|
|
target_compile_options(${target_name}
|
|
|
|
PRIVATE
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wpedantic
|
|
|
|
$<$<CONFIG:RELEASE>:-O2>
|
|
|
|
$<$<CONFIG:DEBUG>:-O0 -g>
|
|
|
|
)
|
|
|
|
elseif(NOT CMAKE_COMPILER_IS_GNU<C++>)
|
|
|
|
# clang, no prof
|
|
|
|
target_compile_options(${target_name}
|
|
|
|
PRIVATE
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wpedantic
|
|
|
|
$<$<CONFIG:RELEASE>:-O2>
|
|
|
|
$<$<CONFIG:DEBUG>:-O0 -g -pg>
|
|
|
|
)
|
2021-08-23 20:30:39 +00:00
|
|
|
else()
|
|
|
|
target_compile_options(${target_name}
|
|
|
|
PRIVATE
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wpedantic
|
|
|
|
$<$<CONFIG:RELEASE>:-O2>
|
|
|
|
$<$<CONFIG:DEBUG>:-O0 -g -p -pg>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endfunction()
|