Skip to content

Commit 05ee391

Browse files
committed
add PreventInSourceBuilds
1 parent 8d9e8eb commit 05ee391

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.26)
22

3+
include(cmake/PreventInSourceBuilds.cmake)
4+
35
project(
46
Template-CPP
57
VERSION 0.1.0

cmake/PreventInSourceBuilds.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ---- In-source guard ----
2+
3+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
4+
message(
5+
FATAL_ERROR
6+
"In-source builds are not supported. "
7+
"You may need to delete 'CMakeCache.txt' and 'CMakeFiles/' first."
8+
)
9+
endif()

0 commit comments

Comments
 (0)