Mas Bagol
Mas Bagol

Reputation: 4617

How to use cmakedefine preprocessor directive properly?

Following this instructions, I create a headerconfig.h.in file which contains #cmakedefine USE_MYLIB. On my main.cpp file i add #include headerconfig.h.in. And, I've set too the CMakeLists.txt file for this. But, I got this:

error: invalid preprocessing directive #cmakedefine

What did I do wrong? Is for some reason cmake can't reade #cmakedefine preprocessore?

Upvotes: 0

Views: 6652

Answers (1)

fghj
fghj

Reputation: 9394

You should include not "headerconfig.h.in", but "headerconfig.h",
and add appropriate configure_file call in your cmake.
The idea is that cmake process headerconfig.h.in and generate headerconfig.h,
replace "#cmakedefine" with real values, and it uses headerconfig.h.in as template.

Upvotes: 5

Related Questions