Search code examples
c++cmakeroot-framework

CMake error: ROOT should be built as an out of source build


I am trying to build the project ROOT. There is a command to build using cmake ../root. Whenever, I try to run this command it gives me this error:

Harshits-Air:root harshitprasad$ cmake ../root
-- Found a Mac OS X System 10.13
-- Found a 64bit system
-- Found LLVM compiler collection
-- ROOT Platform: macosx
-- ROOT Architecture: macosx64
-- Build Type: RelWithDebInfo
-- Compiler Flags:  -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -m64 -pipe -W -Wshadow -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG
CMake Error at cmake/modules/RootNewMacros.cmake:1041 (message):
  ROOT should be built as an out of source build, to keep the source
  directory clean.  Please create a extra build directory and run the command
  'cmake <path_to_source_dir>' in this newly created directory.  You have
  also to delete the directory CMakeFiles and the file CMakeCache.txt in the
  source directory.  Otherwise cmake will complain even if you run it from an
  out-of-source directory.
Call Stack (most recent call first):
  CMakeLists.txt:107 (ROOT_CHECK_OUT_OF_SOURCE_BUILD)

I'm not able to understand what this error means? It would be great if anyone can help me out with this issue. Thanks!


Solution

  • The error message simply tells you to create an additional build folder e.g. build next to the ROOT project folder root, change to this directory and call cmake ../root from there.

    TLDR; To simply call the following sequence starting from the root folder:

    cd ..
    mkdir build
    cd build
    cmake ../root