Add interprocedural optimization flags only when they are supported if clang is in use

This commit is contained in:
Username404 2021-11-12 21:18:11 +01:00
parent c2f70924ef
commit d687544519
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 4 additions and 1 deletions

View File

@ -77,7 +77,10 @@ elseif(${IS_CLANG})
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MINIMAL_CLANG})
message(FATAL_ERROR "Clang ${MINIMAL_CLANG} or higher is required.")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=full -fwhole-program-vtables -fstrict-vtable-pointers")
if (${CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE} OR MINGW) # CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE is false on llvm-mingw toolchains even though it is supported
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=full -fwhole-program-vtables")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fstrict-vtable-pointers")
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
if (UPPERCASE_BUILD_TYPE STREQUAL RELEASE)