[CMake] Forcing 'out-of-source' build

Wylie, Brian bnwylie at sandia.gov
Fri Nov 26 15:24:11 EST 2010


Hi All,

I want to force an 'out-of-source' build for a small project that I converted to use Cmake.

I did a bit of searching and found variants of the following...

# Make sure the build is out of source
STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
  IF(insource)
    MESSAGE(FATAL_ERROR "Do not build in your source dir please :)")
  ENDIF(insource)


It works but it still generates a CMakeCache.txt file and a CMakeFiles directory in the source directory (which I've also seen others discussing)...  is there a more official way to block 'in-source' builds that leaves the source dir pristine?

  Brian Wylie - Org 1424
  Sandia National Laboratories
  MS 1323 - Building CSRI/242
  (505)844-2238 FAX(505)284-2518   
       _______ __
      /_  __(_) /_____ _____
       / / / / __/ __ `/ __ \
      / / / / /_/ /_/ / / / /
     /_/ /_/\__/\__,_/_/ /_/
 Scalable Analysis and Visualization





More information about the CMake mailing list