1 2if(MSVC) 3 add_compile_definitions(SUPPORT_MSVC) 4 add_compile_definitions(_ENABLE_ATOMIC_ALIGNMENT_FIX) 5 set(CMAKE_C_FLAGS "/O2 /EHsc /GS /Zi /utf-8") 6 set(CMAKE_CXX_FLAGS "/O2 /EHsc /GS /Zi /utf-8 /std:c++17") 7 set(CMAKE_SHARED_LINKER_FLAGS "/DEBUG ${SECURE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") 8 set(CMAKE_EXE_LINKER_FLAGS "/DEBUG ${SECURE_SHARED_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") 9else() 10 string(REPLACE "-g" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 11 string(REPLACE "-g" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 12 13 set(CMAKE_C_FLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wall -Werror -Wno-attributes -Wno-deprecated-declarations \ 14 -Wno-missing-braces ${SECURE_C_FLAGS} ${CMAKE_C_FLAGS}") 15 set(CMAKE_CXX_FLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wall -Werror -Wno-attributes -Wno-deprecated-declarations \ 16 -Wno-missing-braces -Wno-overloaded-virtual -std=c++17 ${SECURE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") 17 18 set(CMAKE_C_FLAGS_DEBUG "-DDebug -g -fvisibility=default") 19 set(CMAKE_CXX_FLAGS_DEBUG "-DDebug -g -fvisibility=default") 20 21 if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 22 string(REPLACE "-O2" "-O0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 23 string(REPLACE "-O2" "-O0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 24 endif() 25 set(CMAKE_SHARED_LINKER_FLAGS "${SECURE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") 26 set(CMAKE_EXE_LINKER_FLAGS "${SECURE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") 27endif() 28