1

This question is based on the following SO thread to disable in-source build: while the following setup disable in-source build, it left garbage like "CMakeCache.txt" and "CMakeFiles/". I tried to use file() command to remove it, but it appears no effect. Any idea?

if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
    file(REMOVE CMakeCache.txt)
    message( FATAL_ERROR "In-source builds not allowed.)
endif()
Community
  • 1
  • 1
python152
  • 1,811
  • 2
  • 15
  • 18
  • 1
    Probably, CMake creates `CMakeCache.txt` even after failure in configuration. So removing this file during configuration has no effect. – Tsyvarev Dec 02 '16 at 21:19
  • I think you are right, I tested this with a fake file, and it works as expected. Wonder if there is a solution here ... – python152 Dec 02 '16 at 21:42
  • "garbage" is not the right term. There is a reason that in-source builds are discouraged. You kind of misuse the tool, then don't be surprised it behaves as it likes. – usr1234567 Dec 02 '16 at 21:46

0 Answers0