From 7e09f07b325b6e2a95e11776f23ff97716b7b924 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Fri, 2 Jun 2023 12:34:56 +0200 Subject: [PATCH] Fix Intel Xcode builds with assembly When forcing the source file language to `C`, Xcode enforces the file to be compiled as `C` by appending `-x c` to the compiler command line. For now try to limit the damage and only enforce the language if the ASM and C compilers differ. Reproducer (CMake `3.26.4`, Xcode `14.3`): ``` cmake -S build/cmake -B _b -GXcode -DCMAKE_OSX_ARCHITECTURES=x86_64 cmake --build _b ``` Fix: #3622 --- build/cmake/lib/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index 457b54797..3cab017a7 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -105,7 +105,9 @@ endif () # Our assembly expects to be compiled by a C compiler, and is only enabled for # __GNUC__ compatible compilers. Otherwise all the ASM code is disabled by # macros. -set_source_files_properties(${Sources} PROPERTIES LANGUAGE C) +if(NOT CMAKE_ASM_COMPILER STREQUAL CMAKE_C_COMPILER) + set_source_files_properties(${Sources} PROPERTIES LANGUAGE C) +endif() macro (add_definition target var) if (NOT ("${${var}}" STREQUAL ""))