DigitalInBlue / Celero

C++ Benchmark Authoring Library/Framework
Other
823 stars 96 forks source link

Configuration error in experimental mode if building in source directory #71

Closed Gluttton closed 9 years ago

Gluttton commented 9 years ago
$ cat /etc/issue
Ubuntu 14.10 \n \l

$ cmake --version
cmake version 2.8.12.2

$ cmake -DCELERO_ENABLE_EXPERIMENTS=ON .
-- The C compiler identification is GNU 4.9.1
-- The CXX compiler identification is GNU 4.9.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- SYSTEM: Linux
CMAKE_CXX_COMPILER: /usr/bin/c++
CMake Error at experiments/CMakeLists.txt:6 (ADD_SUBDIRECTORY):
  The source directory

    /home/gluttton/Projects/Celero/experiments/CMakeFiles

  does not contain a CMakeLists.txt file.

-- Configuring incomplete, errors occurred!
See also "/home/gluttton/Projects/Celero/CMakeFiles/CMakeOutput.log".

This occurs because script inside experiments/CMakeLists.txt try to find CMakeLists.txt inside CMake build directory.

To prevent such errors I propose add something like:

if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
    message (FATAL_ERROR "Prevented in-tree build. This is not allowed in experimental mode.")
endif (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})

in experiments/CMakeLists.txt.

DigitalInBlue commented 9 years ago

See issue #60 and issue #69. In general, I think your proposed solution looks good. I will add that to the next update.