浏览代码

Clang: Implement CMAKE_${LANG}_COMPILER_TARGET for all variants on windows

Fixes: #21097
Thomas Bernard 5 年之前
父节点
当前提交
cf83758b24

+ 1 - 1
Modules/CMakeDetermineCCompiler.cmake

@@ -88,7 +88,7 @@ else()
     )
 endif()
 if(CMAKE_C_COMPILER_TARGET)
-  list(PREPEND CMAKE_C_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_C_COMPILER_TARGET}")
+  set(CMAKE_C_COMPILER_ID_TEST_FLAGS_FIRST "-c --target=${CMAKE_C_COMPILER_TARGET}")
 endif()
 # Build a small source file to identify the compiler.
 if(NOT CMAKE_C_COMPILER_ID_RUN)

+ 1 - 1
Modules/CMakeDetermineCXXCompiler.cmake

@@ -84,7 +84,7 @@ else()
 endif()
 
 if(CMAKE_CXX_COMPILER_TARGET)
-  list(PREPEND CMAKE_CXX_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_CXX_COMPILER_TARGET}")
+  set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS_FIRST "-c --target=${CMAKE_CXX_COMPILER_TARGET}")
 endif()
 
 # Build a small source file to identify the compiler.

+ 12 - 3
Modules/Platform/Windows-Clang.cmake

@@ -163,7 +163,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
     include(Platform/Windows-MSVC)
     # Set the clang option forwarding prefix for clang-cl usage in the llvm-rc processing stage
     __enable_llvm_rc_preprocessing("-clang:")
-    macro(__windows_compiler_clang lang)
+    macro(__windows_compiler_clang_base lang)
       set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}")
       __windows_compiler_msvc(${lang})
     endmacro()
@@ -179,7 +179,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
     set(CMAKE_BUILD_TYPE_INIT Debug)
 
     __enable_llvm_rc_preprocessing("")
-    macro(__windows_compiler_clang lang)
+    macro(__windows_compiler_clang_base lang)
       __windows_compiler_clang_gnu(${lang})
     endmacro()
   endif()
@@ -187,7 +187,16 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
 else()
   include(Platform/Windows-GNU)
   __enable_llvm_rc_preprocessing("")
-  macro(__windows_compiler_clang lang)
+  macro(__windows_compiler_clang_base lang)
     __windows_compiler_gnu(${lang})
   endmacro()
 endif()
+
+macro(__windows_compiler_clang lang)
+  if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0)
+    set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ")
+  else()
+    set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=")
+  endif()
+  __windows_compiler_clang_base(${lang})
+endmacro()

+ 0 - 5
Modules/Platform/Windows-MSVC.cmake

@@ -364,11 +364,6 @@ macro(__windows_compiler_msvc lang)
     set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
     set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
 
-    if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0)
-      set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ")
-    else()
-      set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=")
-    endif()
     # '-flto=thin' available since Clang 3.9 and Xcode 8
     # * http://clang.llvm.org/docs/ThinLTO.html#clang-llvm
     # * https://trac.macports.org/wiki/XcodeVersionInfo