Closed DaanDeMeyer closed 8 years ago
You may find the entries on add_definitions and PROJECT_SOURCE_DIR to be of interest.
In this specific case, add_definitions(-DPROJECT_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\")
adds the project source directory as a preprocessor directive.
Does that answer your question?
Thanks, but why is it necessary to do this? I'm not incredibly familiar with CMake which is why I'm asking.
It's not strictly mandatory, but can be helpful if you generate both makefiles and IDE project files and you need to perform file operations. The former uses just the project root, but the latter option can be problematic since different IDEs have different project layouts. Providing the project source directory as a preprocessor directive allows you to open files from a uniform directory, rather than mucking around with relative directories that may move depending on where your binary is generated.
Alright, thank you for taking the time to explain everything!
I was wondering what the effect was of adding the DPROJECT_SOURCE_DIR compile definition in CmakeLists.txt.