summaryrefslogtreecommitdiff
path: root/Modules/CMakeDetermineCCompiler.cmake
diff options
context:
space:
mode:
authorThomas Bernard <tbernard@go-engineering.de>2020-07-28 19:48:47 +0200
committerThomas Bernard <tbernard@go-engineering.de>2020-07-28 19:48:47 +0200
commit270e0d9c4d47821b884b87b4f69129d7f2b80677 (patch)
tree08f100774701c9a523292aa16606e6dfbbe5da0b /Modules/CMakeDetermineCCompiler.cmake
parente4e899056eca97e62d40d47bf4ee2a4871553751 (diff)
downloadcmake-270e0d9c4d47821b884b87b4f69129d7f2b80677.tar.gz
Detect the correct target architecture for clang compilers.
During compiler identification, if CMAKE_{C,CXX}_COMPILER_TARGET is defined, the corresponding clang target flag is used to guaranty proper target architecture detection.
Diffstat (limited to 'Modules/CMakeDetermineCCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index 86683d1bad..13117199de 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -87,7 +87,9 @@ else()
"--target=arm-arm-none-eabi -mcpu=cortex-m3"
)
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.
if(NOT CMAKE_C_COMPILER_ID_RUN)
set(CMAKE_C_COMPILER_ID_RUN 1)