Search code examples
cmakefirebreath

can firebreath pre-defined function configure_template support @ONLY?


Now I am using Firebreath to development my plugin, and I got an issue to use Firebreath pre-defined configure_template function.

As far as I see now, configure_template will substitute the variables referenced as ${VAR} or @VAR@ or the @@foreach loop.

but my configure file (nsis installer file) has its own defined variables as ${VAR}, so I don't want it to be substituted by configure_template.

The reason that I use Firebreath pre-defined configure_template instead of configure_file(inputfile outputfile @ONLY) is that I want to use @@foreach loop in my configure file to interpret a semicolon CMAKE variable.

So, how should I solve this issue? Can I easily modify the exist configure_template so as to ignore ${VAR}, or there are alternative ways to interpret a semicolon CMAKE variable in my configure file?


Solution

  • I just figure out one solution myself.

    The existing configure_template function provided by Firebreath can be modified to ignore substitute variables like ${VAR}. The modification is simple, which is just one line, Change the following code

    string(CONFIGURE "${line}" line ESCAPE_QUOTES)
    

    to

    string(CONFIGURE "${line}" line ESCAPE_QUOTES @ONLY)
    

    The @ONLY parameter will tell CMAKE to only substitute variables like @VAR@.

    Though, this can solve the problem of configuring my own file, but this will broke the Firebreath specific configuration file, as they all use ${VAR}.

    So, my final solution is

    1. Copy the Firebreath's configure_template.cmake out, rename and modify.
    2. Use the modified version of my_configure_template to serve my purpose, then it won't affect the existing configure_template behaviors.

    Any other solutions are welcomed.