# Handling gcc/g++ '--param' flag

**URL:** https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408
**Category:** Code
**Tags:** comp:gcc, comp:clang
**Created:** [June 26, 2023, 1:02am UTC](https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408 "2023-06-26T01:02:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ct\_clmsn](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ct_clmsn/32/3556_2.png) [@ct\_clmsn](https://discourse.cmake.org/u/ct_clmsn)
#### Post date: [June 26, 2023, 1:02am UTC](https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408/1 "2023-06-26T01:02:47Z")

</div>

A project I’m currently working on requires a dependency that has pkg-config support.

Cmake currently does everything right with one exception, several of the cxx-flags have a ‘–param’ prefix to indicate specific constraints to the optimizer.

Cmake takes the following from the pkg-config \*.pc file in a dependency

‘–param optimizer\_a=10000 --param optimizer\_b=10000’

and converts it into

‘–param;optimizer\_a=10000;–param;optimizer\_b=10000’

in the CMakeCache.txt

When make is executed with ‘VERBOSE=1’ the following output appears

‘–param optimizer\_a=10000 optimizer\_b=10000’

A compilation error is thrown and the build terminates.

Is there a preferred method for handling this situation?

Thanks in advance,

Chris

---

<div class="post-metadata">

### Author: ![ct\_clmsn](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ct_clmsn/32/3556_2.png) [@ct\_clmsn](https://discourse.cmake.org/u/ct_clmsn)
#### Post date: [June 26, 2023, 11:23pm UTC](https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408/2 "2023-06-26T23:23:56Z")

</div>

The issue is that cmake is applying de-deduplication to the pkgconfig variables when they’re loaded into cmake (from the pkg-config file). Is there any way to turn off deduplication for specific flags like ‘–param’ or is the best practice to write loops that attempt to correct for the deduplication? (prefix values with “SHELL:”)

[https://cmake.org/cmake/help/latest/prop\_tgt/COMPILE\_OPTIONS.html#option-de-duplication](https://cmake.org/cmake/help/latest/prop_tgt/COMPILE_OPTIONS.html#option-de-duplication)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 1, 2023, 8:51pm UTC](https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408/3 "2023-07-01T20:51:39Z")

</div>

`SHELL:` would be the thing to munge in, yes.

---

<div class="post-metadata">

### Author: ![ct\_clmsn](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ct_clmsn/32/3556_2.png) [@ct\_clmsn](https://discourse.cmake.org/u/ct_clmsn)
#### Post date: [July 1, 2023, 9:02pm UTC](https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408/4 "2023-07-01T21:02:51Z")

</div>

I attempted to filter out the --param variables and the code works. When the filtered list prints at runtime, all the variables are filtered out.

However, when the build runs and I look at CMakeCache, the variables aren’t removed and the build crashes. I have no idea what is going on. Its as if my changes to the variables arent retained or are ignored - are the variables immutable?

Do you have a recommendation regarding this issue?

Thanks in advance.

ct

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 1, 2023, 9:49pm UTC](https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408/5 "2023-07-01T21:49:48Z")

</div>

Most commands work on local variables and won’t touch the cache. As long as your code runs on every `find_package()` for the offending package, it should mask what the cache says.
