From c66162c4a5f148ad51a939b54fcc4c821fc81133 Mon Sep 17 00:00:00 2001 From: tomeichlersmith Date: Wed, 27 Sep 2023 14:45:17 -0500 Subject: [PATCH] move check higher so that it actually errors out --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1af95860..6dcc269f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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." @@ -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()