0

I wanted to avoid in-source build, so I wrote code like below...

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
   message(FETAL_ERROR "in-source build is forbidden")
endif()

It emitted that message, but cmake did not stop processing. Now my source directory is polluted...
How to prevent this?

a.tana
  • 41
  • 7
  • `FETAL_ERROR` It's `FATAL_ERROR` – KamilCuk Jul 27 '22 at 12:11
  • @KamilCuk lol thanks. but cmake still creates some artifacts in my source directory. This is annoying. – a.tana Jul 27 '22 at 12:15
  • 2
    "t emitted that message, but cmake did not stop processing." - CMake stops processing. The files you found in your source directory are created **before** CMake executes your code. According to the error message, you are attempting to prohibit in-source builds. See [that question](https://stackoverflow.com/questions/1208681/with-cmake-how-would-you-disable-in-source-builds) for more details about this topic. See also that [recent question](https://stackoverflow.com/questions/73083662/prohibit-cmake-build-on-the-top-level-source) about avoiding of polluting the source directory. – Tsyvarev Jul 27 '22 at 13:45

0 Answers0