Search code examples
cmakecmake-gui

CMake build directory (chosen in gui) variable


While running the cmake's script, I would like to obtain the path to the main build folder, which one chooses, for example in CMake Gui via "Where to build the binaries" text input.

Best match that I have found so far is the PROJECT_BINARY_DIR variable, that unfortunately gets you the folder: ./build/modules/project_name.

I would like to get the .../build folder only.

I know I can extract .../build from .../build/modules/project_name with some hacking but would anyway like to get the .../build directly!


Solution

  • CMAKE_BINARY_DIR is what you are looking for. It is an absolute path to the top level folder of your build directory.