I'm working with an existing project and cleaning up the CMake for it. However, right now I'm a bit confused by how exactly to go about integrating the CMake options into the actual source code.
For simplicity's sake, let's say I'd like to only execute one chunk of code, let's say cout << "print";, inside example.cpp if, on CMake, the value ENABLE_PRINT is set to ON.
The project directory will look like this:

Using the above example, I did the following:
- On the parent project
CMakeLists.txt, I addedOPTION( ENABLE_PRINT "Enable Print" ON) - Then, on the example subproject source folder
Config.hfile, I added#define ENABLE_PRINT - On the
Config.h.inlocated in the example subproject, I added#cmakedefine ENABLE_PRINT - Finally, on the source file
example.cpp, I encircledcout << "print";inside#ifdef ENABLE_PRINTand#endif
After making those changes, the project will configure and generate just fine. However, when I make the software, it will error and essentially tell me that the chunk of code I encircled with #ifdef was not executed at all; it was ignored. In other words, the above steps I took did not do anything except "comment out" the chunk of code I wanted to make conditional upon ENABLE_PRINT.
So, how would I make this work?