CMake: Do not enable LTO by default for MSVC
LTO is supposed to be enabled by default for VS Release builds according to the VS prop files but a build log from JMC reveals that /GL and /LTCG are not actually passed to cl.exe/link.exe for some reason... LTO also leads to *extremely* and unacceptably slow build times when using link.exe, so let's disable it by default to actually match the project files.
This commit is contained in:
parent
d0484a9ea9
commit
ae9ac510e2
|
@ -332,10 +332,15 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LTO)
|
if(ENABLE_LTO)
|
||||||
check_and_add_flag(LTO -flto)
|
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
add_compile_options(/GL)
|
||||||
set(CMAKE_AR gcc-ar)
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " /LTCG")
|
||||||
set(CMAKE_RANLIB gcc-ranlib)
|
else()
|
||||||
|
check_and_add_flag(LTO -flto)
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||||
|
set(CMAKE_AR gcc-ar)
|
||||||
|
set(CMAKE_RANLIB gcc-ranlib)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -362,11 +367,6 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||||
"Build type (Release/Debug/RelWithDebInfo/MinSizeRel)" FORCE)
|
"Build type (Release/Debug/RelWithDebInfo/MinSizeRel)" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo" AND CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
|
||||||
add_compile_options(/GL)
|
|
||||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " /LTCG")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ENABLE_GPROF)
|
if(ENABLE_GPROF)
|
||||||
check_and_add_flag(HAVE_PG -pg)
|
check_and_add_flag(HAVE_PG -pg)
|
||||||
if(NOT FLAG_C_HAVE_PG)
|
if(NOT FLAG_C_HAVE_PG)
|
||||||
|
|
Loading…
Reference in New Issue