1

I have a project in Linux which its build tool is CMake version 3.5. When I enter "cmake ." command in my project folder, cmake automatically create a folder "CmakeFiles" and several other cache files in my project folder. I want to create another folder called "cache" in my project folder and put all of cmake cache files in it. How can I do that explicitly within "CMakeList.txt" file? I do search stack and other resources but not able to find out any solution. FYI, in CLion IDE, this is so simple. You can change the cache and build files path like below;

enter image description here

Reza
  • 3,473
  • 4
  • 35
  • 54

1 Answers1

4

This is also very simple with just CMake: just run it from the directory you want cache to be in:

cd your_project
mkdir build
cd build
cmake ../
arrowd
  • 33,231
  • 8
  • 79
  • 110
  • 2
    Thanks for your answer. But what about if I want to do it explicitly in "CMakeLists.txt" file? – Reza Jul 03 '17 at 14:38
  • 3
    Well, there is no reason to fix build directory. The user may want it to be whenever he wishes, even outside of project dir. So, I doubt you can enforce `CMAKE_BINARY_DIR` (that's how that variable is called) to some value from CMakeLists.txt. – arrowd Jul 03 '17 at 14:41