# Deprecation warnings with clang when setting LANGUAGE property

**URL:** https://discourse.cmake.org/t/deprecation-warnings-with-clang-when-setting-language-property/6490
**Category:** Development
**Created:** [September 15, 2022, 12:50am UTC](https://discourse.cmake.org/t/deprecation-warnings-with-clang-when-setting-language-property/6490 "2022-09-15T00:50:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sszabo](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sszabo/32/6030_2.png) [@sszabo](https://discourse.cmake.org/u/sszabo)
#### Post date: [September 15, 2022, 12:50am UTC](https://discourse.cmake.org/t/deprecation-warnings-with-clang-when-setting-language-property/6490/1 "2022-09-15T00:50:01Z")

</div>

With CMake 3.16.3 and 3.23.1 at least, when using CC=clang CXX=clang++ and doing a CMakeLists.txt like the following (simplified from the case in the WebKit code) I see a deprecation warning about .c files being treated as c++ when in c++ mode:

```auto
cmake_minimum_required(VERSION 3.13)
project(testproj)
add_executable(app app.c)
set_source_files_properties(app.c PROPERTIES LANGUAGE CXX)

```

and a simple app.c

```auto
int main() {}

```

The command being run seems to be

```auto
/usr/bin/clang++ -o CMakeFiles/app.dir/app.c.o -c /home/szabos1/cmtest/app.c

```

which gives

```auto
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

```

Using app.q rather than app.c, I got an error instead as it doesn’t generate an output file for ‘linker’ input.

I’m not sure if these sorts of cases where one overrides the language for a file is expected to work without the warning/errors.

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [September 15, 2022, 5:57am UTC](https://discourse.cmake.org/t/deprecation-warnings-with-clang-when-setting-language-property/6490/2 "2022-09-15T05:57:59Z")

</div>

I don’t think it can.  
You have told CMake to use C++ compiler to compile `app.c` and it did. The C++ compiler you use warns in this situation. If you know, what you’re doing either ignore the warning or add `-Wno-deprecated` for that file but rather don’t expect some auto-magic 😉

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [September 15, 2022, 12:19pm UTC](https://discourse.cmake.org/t/deprecation-warnings-with-clang-when-setting-language-property/6490/3 "2022-09-15T12:19:10Z")

</div>

See [policy CMP0119](https://cmake.org/cmake/help/v3.24/policy/CMP0119.html), which updates the `LANGUAGE` property to also add `-x c++`. If you bump your `cmake_minimum_required` call to `3.20` or higher, the policy’s `NEW` behavior will be used automatically.

---

<div class="post-metadata">

### Author: ![sszabo](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sszabo/32/6030_2.png) [@sszabo](https://discourse.cmake.org/u/sszabo)
#### Post date: [September 15, 2022, 4:38pm UTC](https://discourse.cmake.org/t/deprecation-warnings-with-clang-when-setting-language-property/6490/4 "2022-09-15T16:38:44Z")

</div>

Thanks, I forgot to check for a policy. I think the WebKit side needs to support pre 3.20 for some ports, but we’re past that for our port anyway.
