2022-05-09 15:57:31 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
|
|
|
set(GENERAL_FLAGS "-pthread")
|
|
|
|
set(WARNING_FLAGS "-Wall -Wextra")
|
2024-07-28 17:48:15 +00:00
|
|
|
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -s")
|
2024-02-12 13:48:45 +00:00
|
|
|
|
|
|
|
if (WITH_LTO)
|
2024-02-15 18:25:31 +00:00
|
|
|
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} -flto=auto -fuse-linker-plugin")
|
2024-02-12 13:48:45 +00:00
|
|
|
endif()
|
2022-05-09 15:57:31 +00:00
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
else()
|
|
|
|
if (STATIC_BINARY)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
else()
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
|
|
|
set(GENERAL_FLAGS "")
|
2023-08-16 11:00:11 +00:00
|
|
|
set(WARNING_FLAGS "/W4 /sdl")
|
2022-05-09 15:57:31 +00:00
|
|
|
set(SECURITY_FLAGS "/GS /guard:cf")
|
|
|
|
set(OPTIMIZATION_FLAGS "/O2 /Oi /Ob2 /Ot /DNDEBUG /GL")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${GENERAL_FLAGS} ${WARNING_FLAGS} ${SECURITY_FLAGS} /Od /Ob0 /Zi /MTd /fsanitize=address")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${GENERAL_FLAGS} ${WARNING_FLAGS} ${SECURITY_FLAGS} /Od /Ob0 /Zi /MTd /fsanitize=address")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${GENERAL_FLAGS} ${WARNING_FLAGS} ${SECURITY_FLAGS} ${OPTIMIZATION_FLAGS} /MT")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${GENERAL_FLAGS} ${WARNING_FLAGS} ${SECURITY_FLAGS} ${OPTIMIZATION_FLAGS} /MT")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${GENERAL_FLAGS} ${WARNING_FLAGS} ${SECURITY_FLAGS} /Ob1 /Ot /Zi /MT")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${GENERAL_FLAGS} ${WARNING_FLAGS} ${SECURITY_FLAGS} /Ob1 /Ot /Zi /MT")
|
|
|
|
|
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
2023-08-15 11:31:28 +00:00
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
else()
|
|
|
|
set(GENERAL_FLAGS "-pthread")
|
|
|
|
endif()
|
|
|
|
|
2022-05-09 15:57:31 +00:00
|
|
|
set(WARNING_FLAGS "-Wall -Wextra -Wno-undefined-internal")
|
2024-07-28 17:48:15 +00:00
|
|
|
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -funroll-loops -fmerge-all-constants")
|
2024-02-12 13:48:45 +00:00
|
|
|
|
|
|
|
if (WITH_LTO)
|
|
|
|
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} -flto")
|
|
|
|
endif()
|
2022-05-09 15:57:31 +00:00
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
endif()
|