I want to disallow people from cluttering our source tree with generated CMake files... and, more importantly, disallow them from stepping on existing Makefiles
that are not part of the same build process we're using CMake for. (best not to ask)
The way I have come up with to do this is to have a few lines at the top of my CMakeLists.txt
, as follows:
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(SEND_ERROR "In-source builds are not allowed.")
endif("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
However, doing it this way seems too verbose. Additionally, if I try an in-source build it still creates the the CMakeFiles/
directory, and the CMakeCache.txt
file in the source tree before the error is thrown.
Am I missing a better way to do this?
CMake has two undocumented options:
CMAKE_DISABLE_SOURCE_CHANGES
andCMAKE_DISABLE_IN_SOURCE_BUILD
-
/home/selivanov/cmake-2.8.8/Source/cmMakefile.cxx