Skip to content

Commit

Permalink
fatal error if we detect an in-source build
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeichlersmith authored Sep 27, 2023
1 parent c7fb56a commit 63857a1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ 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 63857a1

Please sign in to comment.