# cmake puts compiler flags in link commands on ninja file

**URL:** <https://discourse.cmake.org/t/cmake-puts-compiler-flags-in-link-commands-on-ninja-file/4408>\
**Category:** Code\
**Tags:** os:windows, gen:ninja, os:linux\
**Created:** [November 3, 2021, 8:39am UTC](https://discourse.cmake.org/t/cmake-puts-compiler-flags-in-link-commands-on-ninja-file/4408 "2021-11-03T08:39:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FROMAGMA](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@FROMAGMA](https://discourse.cmake.org/u/FROMAGMA)\
**Post date:** [November 3, 2021, 8:39am UTC](https://discourse.cmake.org/t/cmake-puts-compiler-flags-in-link-commands-on-ninja-file/4408/1 "2021-11-03T08:39:40Z")

</div>

Hi,

We are using CMake 3.21 and Ninja 1.10.2 under Windows and Linux.  
We are experimental using Intel oneApi icx compiler.  
At the linking step we get a warning (Linux)  
clang++: warning: argument unused during compilation: ‘-inline-level=0’ [-Wunused-command-line-argument]  
After inspecting the Ninja file I found out that is set  
FLAGS = compile flags  
in the linking step. I think this is unnecessary, can this be disabled?

Thanks in advance and best regards  
Frank

---

<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:** [November 3, 2021, 1:06pm UTC](https://discourse.cmake.org/t/cmake-puts-compiler-flags-in-link-commands-on-ninja-file/4408/2 "2021-11-03T13:06:14Z")

</div>

Where did you specify the `-inline-level=0` compiler flag? `CMAKE_CXX_FLAGS` are used any time the `CMAKE_CXX_COMPILER` is called, even when used to drive linking. There are other ways to add compile-only flags, such as `target_compile_options`.

---

<div class="post-metadata">

**Author:** ![FROMAGMA](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@FROMAGMA](https://discourse.cmake.org/u/FROMAGMA)\
**Post date:** [November 3, 2021, 1:59pm UTC](https://discourse.cmake.org/t/cmake-puts-compiler-flags-in-link-commands-on-ninja-file/4408/3 "2021-11-03T13:59:28Z")

</div>

We set global C, CXX , Fortran Compile flags.  
in the CMAKE\_###\_FLAGS variable

---

<div class="post-metadata">

**Author:** ![FROMAGMA](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@FROMAGMA](https://discourse.cmake.org/u/FROMAGMA)\
**Post date:** [November 8, 2021, 12:22pm UTC](https://discourse.cmake.org/t/cmake-puts-compiler-flags-in-link-commands-on-ninja-file/4408/4 "2021-11-08T12:22:38Z")

</div>

Hi,

Is it possible to set the compile flags to zero for the target which get’s linked?  
I…e remove compile flags via properties?

Best regards  
Frank
