Disabling in-source builds
Let's learn about disabling in-source builds in CMake.
We'll cover the following
It is always recommended to specify the build path as out-of-source. This not only allows for a cleaner build tree and a simpler .gitignore
file, but it also decreases the chances we'll accidentally overwrite or delete any source files. Disabling the in-source build can also be a good solution; however, there is little documented information available on that.
Support for disabling in-source build
Searching for the solution online, you may stumble on a StackOverflow thread that asks the same question. Here, the author notices that no matter what we do, it seems like CMake will still create a CMakeFiles/
directory and a CMakesCache.txt
file. Some answers suggest using undocumented variables to make sure that the user can't write in the source directory under any circumstances:
Get hands-on with 1200+ tech skills courses.