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

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


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,


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:”)


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

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.


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.