# Compiler options with hardening flags function(add_warnings_optimizations target_name) if(MSVC) target_compile_options(${target_name} PRIVATE /W4 /permissive- $<$:/O2 /Ob2> $<$:/O1 /Ob1> $<$:/Zi /O2 /Ob1> $<$:/Zi /Ob0 /Od /RTC1> ) elseif(NOT CMAKE_COMPILER_IS_GNU AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Android") # clang on Android, no prof/gprof target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic $<$:-O2> $<$:-O0 -g> ) elseif(NOT CMAKE_COMPILER_IS_GNU) # clang, no prof target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic $<$:-O2> $<$:-O0 -g -pg> ) else() target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic $<$:-O2> $<$:-O0 -g -p -pg> ) endif() endfunction()