Explorar o código

Merge topic 'use_COMPILER_TARGET_to_set_architecture_for_clang_cl'

270e0d9c4d Detect the correct target architecture for clang compilers.

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5058
Brad King %!s(int64=5) %!d(string=hai) anos
pai
achega
b7522e48a4

+ 3 - 1
Modules/CMakeDetermineCCompiler.cmake

@@ -87,7 +87,9 @@ else()
     "--target=arm-arm-none-eabi -mcpu=cortex-m3"
     "--target=arm-arm-none-eabi -mcpu=cortex-m3"
     )
     )
 endif()
 endif()
-
+if(CMAKE_C_COMPILER_TARGET)
+  list(PREPEND CMAKE_C_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_C_COMPILER_TARGET}")
+endif()
 # Build a small source file to identify the compiler.
 # Build a small source file to identify the compiler.
 if(NOT CMAKE_C_COMPILER_ID_RUN)
 if(NOT CMAKE_C_COMPILER_ID_RUN)
   set(CMAKE_C_COMPILER_ID_RUN 1)
   set(CMAKE_C_COMPILER_ID_RUN 1)

+ 4 - 0
Modules/CMakeDetermineCXXCompiler.cmake

@@ -83,6 +83,10 @@ else()
     )
     )
 endif()
 endif()
 
 
+if(CMAKE_CXX_COMPILER_TARGET)
+  list(PREPEND CMAKE_CXX_COPMILER_ID_TEST_FLAGS "-c --target=${CMAKE_CXX_COMPILER_TARGET}")
+endif()
+
 # Build a small source file to identify the compiler.
 # Build a small source file to identify the compiler.
 if(NOT CMAKE_CXX_COMPILER_ID_RUN)
 if(NOT CMAKE_CXX_COMPILER_ID_RUN)
   set(CMAKE_CXX_COMPILER_ID_RUN 1)
   set(CMAKE_CXX_COMPILER_ID_RUN 1)

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

@@ -356,6 +356,11 @@ macro(__windows_compiler_msvc lang)
     set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
     set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
     set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER 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
     # '-flto=thin' available since Clang 3.9 and Xcode 8
     # * http://clang.llvm.org/docs/ThinLTO.html#clang-llvm
     # * http://clang.llvm.org/docs/ThinLTO.html#clang-llvm
     # * https://trac.macports.org/wiki/XcodeVersionInfo
     # * https://trac.macports.org/wiki/XcodeVersionInfo