# set CMAKE\_CXX\_FLGAS composed of variables without parenthesis, not a good idea ?

**URL:** <https://discourse.cmake.org/t/set-cmake-cxx-flgas-composed-of-variables-without-parenthesis-not-a-good-idea/1907>\
**Category:** Code\
**Created:** [September 24, 2020, 11:08am UTC](https://discourse.cmake.org/t/set-cmake-cxx-flgas-composed-of-variables-without-parenthesis-not-a-good-idea/1907 "2020-09-24T11:08:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ProTur1](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Post date:** [September 24, 2020, 11:08am UTC](https://discourse.cmake.org/t/set-cmake-cxx-flgas-composed-of-variables-without-parenthesis-not-a-good-idea/1907/1 "2020-09-24T11:08:48Z")

</div>

Why does `set(CMAKE_CXX_FLGAS "${CMAKE_CXX_FLAGS} ${extra_flags}")` works, but `set(CMAKE_CXX_FLGAS ${CMAKE_CXX_FLAGS} ${extra_flags})` doesn’t ?

In my case, I got the g++ error: " `no input files` because of the above.

---

<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:** [September 24, 2020, 12:38pm UTC](https://discourse.cmake.org/t/set-cmake-cxx-flgas-composed-of-variables-without-parenthesis-not-a-good-idea/1907/2 "2020-09-24T12:38:55Z")

</div>

`CMAKE_CXX_FLAGS` **must** be defined as a string, not a list.

The second example, without quotes, will be interpreted as a list so each item will be separated by a semi-colon.

For example, if `CMAKE_CXX_FLAGS` contains the string “-c -std=c++11” and `extra_flags` contains ‘-O2’ :

```cmake
# quotes are not specified
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${extra_flags})

```

Now `CMAKE_CXX_FLAGS` contains “-c;-std=c++11;-O2” which not what is expected.

---

<div class="post-metadata">

**Author:** ![ProTur1](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Post date:** [September 24, 2020, 12:46pm UTC](https://discourse.cmake.org/t/set-cmake-cxx-flgas-composed-of-variables-without-parenthesis-not-a-good-idea/1907/3 "2020-09-24T12:46:10Z")

</div>

> [@marc.chevrier](#):
>
> Now `CMAKE_CXX_FLAGS` contains “-c;-std=c++11;-O2” which not what is expected.

Whereas the `;` in bash/make would mean start a new command.

Thanks.
