Remove /LTCG from when compiling with clang-cl (#9765)
authork.h.lai <dlshcbmuipmam@hotmail.com>
Mon, 27 Apr 2020 18:44:52 +0000 (02:44 +0800)
committerGitHub <noreply@github.com>
Mon, 27 Apr 2020 18:44:52 +0000 (20:44 +0200)
Remove /LTCG from CMAKE_EXE_LINKER_FLAGS_RELEASE when compiling with clang on Windows

src/CMakeLists.txt

index dbd6b59226583c78063ad0e0e59960f6341841f8..b416faaf304c166a90eeb5b1afa709ca55d1df7d 100644 (file)
@@ -676,9 +676,12 @@ if(MSVC)
        if(CMAKE_SIZEOF_VOID_P EQUAL 4)
                set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:SSE")
        endif()
-       #set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
-       set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF")
-
+       
+       if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+               set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF")
+       else()
+               set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF")
+       endif()
 
        set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")