]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix Intel Xcode builds with assembly 3665/head
authorGregor Jasny <gjasny@googlemail.com>
Fri, 2 Jun 2023 10:34:56 +0000 (12:34 +0200)
committerGregor Jasny <gjasny@googlemail.com>
Fri, 2 Jun 2023 10:43:59 +0000 (12:43 +0200)
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

index 457b547978ab9ea2d92e31f756c6dccdb4e5ce59..3cab017a7ce34115372df6b6139065f72e3fac8b 100644 (file)
@@ -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 ""))