Skip to content

Define C++ pre-processor code via SEMMacroBuildCLI #27

@finetjul

Description

@finetjul

Sometimes it is useful to pass CMake variables into C++ code. The way to do it is to use the CMake configure_file() macro. It takes a *.h.in as input and generate a .h file.
SEMMacroBuildCLI already generate a *CLP.h file. It would be great if we could define pre-processor variables by passing a simple SEMMacroBuildCLI parameter. For example:
in cmake:

SEMMacroBuildCLI( MyCLI PREPROCESSOR MY_CMAKE_VARIABLE ...)

If MY_CMAKE_VARIABLE is True, that would generate in the CLP.h file:
#define MY_CMAKE_VARIABLE
which could then be used in the MyCLI.cxx file:

int main(int argc, char* argv[])
{
  PARSE_ARGS
#ifdefined MY_CMAKE_VARIABLE
  // do something here
#endif
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions