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