domlao
domlao

Reputation: 16029

Make a macro script in cmake and call that macro in source file

Is it possible to create a macro in cmake. And that macro will be call in the C++ source files. Like,

#include path(file.h)

This path() was defined in a cmake file. I think it will generate the definition in the generated makefiles.

Please advise.

Thanks

Upvotes: 1

Views: 413

Answers (1)

Aleksey Bakin
Aleksey Bakin

Reputation: 1536

If you need variables from CMake's scope, you can use configure_file

If you need code generation, I think it's not possible to use CMake's macros. Use other language (sh or python) to write code generator and add_custom_command to your CMakeLists.txt

Upvotes: 1

Related Questions