# Change in behavior wrt LANGUAGE source property?

**URL:** https://discourse.cmake.org/t/change-in-behavior-wrt-language-source-property/4600
**Category:** Usage
**Created:** [December 6, 2021, 8:27am UTC](https://discourse.cmake.org/t/change-in-behavior-wrt-language-source-property/4600 "2021-12-06T08:27:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ingolf](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/977dab/32.png) [@ingolf](https://discourse.cmake.org/u/ingolf)
#### Post date: [December 6, 2021, 8:27am UTC](https://discourse.cmake.org/t/change-in-behavior-wrt-language-source-property/4600/1 "2021-12-06T08:27:10Z")

</div>

Hi,

in our project, we have a few `.S` assembly files which up to now were treated like regular C files (i.e. they were compiled with the same compiler + flags/options as C files). This was achieved by `set_source_files_properties(file1.S file2.S PROPERTIES LANGUAGE C)` before `add_library(foo some.c other.c file1.S file2.S etc.c)`.

As long as project stated `cmake_minimum_required(VERSION 3.17)`, everything was fine with CMake in version 3.21.3. However, the very same CMake adds `-x c` to the compile flags when the project uses `cmake_minimum_required(VERSION 3.20)`; in consequence, `gcc` reports problems with the assembly file.

What is the correct way to tell CMake that the `.S` files are to be compiled in the same way as C language files (i.e. without adding `-x c`)?

Kind regards  
Ingolf

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [December 6, 2021, 11:21am UTC](https://discourse.cmake.org/t/change-in-behavior-wrt-language-source-property/4600/2 "2021-12-06T11:21:39Z")

</div>

From your description, I suppose that your files are not C source but assembly with pre-processing.

So, it is, anyway, an error to specify `C` as language when the files do not contained `C` source…

Maybe this [discussion](https://discourse.cmake.org/t/processing-assembly-files-with-c-preprocessor-statements/3599) can be of some help.

---

<div class="post-metadata">

### Author: ![ingolf](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/977dab/32.png) [@ingolf](https://discourse.cmake.org/u/ingolf)
#### Post date: [December 6, 2021, 11:30am UTC](https://discourse.cmake.org/t/change-in-behavior-wrt-language-source-property/4600/3 "2021-12-06T11:30:37Z")

</div>

@marc.chevrier, I admit that declaring the assembler files C language is kind of wrong. However, up to somwhere between `cmake_minimum_required(VERSION 3.17)` and `... 3.20)`, this was a successful workaround without having cumbersome constructs like `add_custom_command()`.

Isn’t there some official way to tell CMake “please treat this `.S` source file in exactly the same way as you would usually do with `.c` files even if it is no C language file”?

Cheers  
Ingolf

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [December 6, 2021, 11:36am UTC](https://discourse.cmake.org/t/change-in-behavior-wrt-language-source-property/4600/4 "2021-12-06T11:36:24Z")

</div>

Possibly, specify your `C` compiler as `ASM` compiler:

```auto
env ASM=gcc cmake ...

```

And do not specify any `LANGUAGE` for your assembly files.

---

<div class="post-metadata">

### Author: ![ingolf](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/977dab/32.png) [@ingolf](https://discourse.cmake.org/u/ingolf)
#### Post date: [December 6, 2021, 12:00pm UTC](https://discourse.cmake.org/t/change-in-behavior-wrt-language-source-property/4600/5 "2021-12-06T12:00:28Z")

</div>

For the record, I just found the [comments on the `LANGUAGE` property in the context of `CMP0119`](https://cmake.org/cmake/help/latest/policy/CMP0119.html).

Removing `set_source_files_properties(file1.S file2.c PROPERTIES LANGUAGE C)` and instead declaring `enable_language(ASM)` solved my problem. Thanks for your support.

Cheers  
Ingolf
