From a4575a726d14ce42c78e7648ab0c6232dafbd87c Mon Sep 17 00:00:00 2001 From: Username404 Date: Fri, 12 Nov 2021 21:18:11 +0100 Subject: [PATCH] Add interprocedural optimization flags only when they are supported if clang is in use --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cc8687..bdfbae5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)