Skip to content

Commit

Permalink
move check higher so that it actually errors out
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeichlersmith committed Sep 27, 2023
1 parent 63857a1 commit c66162c
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
# Set the minimum version of CMake that's required
cmake_minimum_required(VERSION 3.12)

# make sure the source and binary directories are different
# this is here to prevent so-called "in-source" builds where the root directory of the source
# is also the root directory of the build
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
if ("${srcdir}" STREQUAL "${bindir}")
message(FATAL_ERROR "ldmx-sw does not support in-source builds.
Call 'ldmx cmake ..' from within a 'build/' subdirectory or
Tell cmake to use a different build directory with 'ldmx cmake -B build -S .'")
endif()

# Set the project name
project(LDMX_SW VERSION 3.1.1
DESCRIPTION "The Light Dark Matter eXperiment simulation and reconstruction framework."
Expand Down Expand Up @@ -40,18 +51,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
endif()

# make sure the source and binary directories are different
# this is here to prevent so-called "in-source" builds where the root directory of the source
# is also the root directory of the build
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
if ("${srcdir}" STREQUAL "${bindir}")
message(FATAL_ERROR "ldmx-sw does not support in-source builds.\n"
" Call 'ldmx cmake ..' from within a 'build/' subdirectory or\n"
" Tell cmake to use a different build directory with 'ldmx cmake -B build -S .'"
)
endif()

# Clear any variables cached during previous configuration cycles.
clear_cache_variables()

Expand Down

0 comments on commit c66162c

Please sign in to comment.