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() 
3
  • 1
    Probably, CMake creates CMakeCache.txt even after failure in configuration. So removing this file during configuration has no effect. Commented Dec 2, 2016 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 ... Commented Dec 2, 2016 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. Commented Dec 2, 2016 at 21:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.