Polytonic / Glitter

Dead Simple OpenGL
http://polytonic.github.io/Glitter/
2.48k stars 418 forks source link

Effect of -DPROJECT_SOURCE_DIR? #27

Closed DaanDeMeyer closed 8 years ago

DaanDeMeyer commented 8 years ago

I was wondering what the effect was of adding the DPROJECT_SOURCE_DIR compile definition in CmakeLists.txt.

Polytonic commented 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?

DaanDeMeyer commented 8 years ago

Thanks, but why is it necessary to do this? I'm not incredibly familiar with CMake which is why I'm asking.

Polytonic commented 8 years ago

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.

DaanDeMeyer commented 8 years ago

Alright, thank you for taking the time to explain everything!