From ae67297bf6200ecb6b6a461f57cd490f17f61319 Mon Sep 17 00:00:00 2001 From: doodspav Date: Sat, 18 Mar 2023 15:00:56 +0000 Subject: [PATCH] GHI #13 Prevent in-source build of tests Signed-off-by: doodspav --- cmake/util/PreventInSourceBuilds.cmake | 3 +-- test/CMakeLists.txt | 2 ++ test/cmake/PreventInSourceBuilds.cmake | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/cmake/PreventInSourceBuilds.cmake diff --git a/cmake/util/PreventInSourceBuilds.cmake b/cmake/util/PreventInSourceBuilds.cmake index c78f18825..ef5b59ebb 100644 --- a/cmake/util/PreventInSourceBuilds.cmake +++ b/cmake/util/PreventInSourceBuilds.cmake @@ -3,7 +3,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) message( FATAL_ERROR "In-source builds are not supported. " - "Please read the BUILDING document before trying to build this project. " - "You may need to delete 'CMakeCache.txt' and 'CMakeFiles/' first." + "You may need to delete 'CMakeCache.txt' and 'CMakeFiles/' before rebuilding this project." ) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7718b6034..76886c1c0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.14) +include(cmake/PreventInSourceBuilds.cmake) + project( patomic_test DESCRIPTION "Standalone tests for patomic library" diff --git a/test/cmake/PreventInSourceBuilds.cmake b/test/cmake/PreventInSourceBuilds.cmake new file mode 100644 index 000000000..ef5b59ebb --- /dev/null +++ b/test/cmake/PreventInSourceBuilds.cmake @@ -0,0 +1,8 @@ +# in-source build guard +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message( + FATAL_ERROR + "In-source builds are not supported. " + "You may need to delete 'CMakeCache.txt' and 'CMakeFiles/' before rebuilding this project." + ) +endif()