diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2025-03-24 17:02:05 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2025-03-25 18:55:21 +0100 |
| commit | 8424af743b2ccbc0cabd584216627bed7baad4af (patch) | |
| tree | 9884cb86070b4679b8206e44e039867eb2840428 /CMakeLists.txt | |
| parent | d756076644c16cb74051fa7520f84375263b84c4 (diff) | |
Disallow in-source builds
Rationale:
1. Building in-source creates a lot of untracked files in the source
tree. We need to take care not to commit any of them, hence we
have to maintain .gitignore files in several directories.
2. Tests reveal that there are even files in git that are modified
in the source tree when building docs etc. which means e.g.
that builds can't be "repeated" after upgrading the sources, and
that those files could be committed by accident. To avoid this
we'd have to reorganize the build procedure and make it even more
complex rather than simplifying it.
3. With autoconf/configure/make we didn't have a choice, i.e. we had
to allow in-source builds with configure/Makefiles anyway. This
is no longer true since we removed configure/make support.
Note, todo: if this commit doesn't introduce unexpected issues, then
we can remove a lot of stuff from the .gitignore files, but this
is left for a later commit.
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 420e379c1..08548b2b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,23 @@ # ####################################################################### +# Prevent building in the source tree - don't pollute the sources +####################################################################### + +if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") + message("") + message(STATUS "=======================================================================") + message(STATUS " NOTE: In-source builds of FLTK are disabled to prevent writing to the") + message(STATUS " NOTE: source tree. Please create a subfolder (e.g. 'build') and use") + message(STATUS " NOTE: `cmake ..` inside it or use for instance `cmake . -B build`.") + message(STATUS " NOTE: CMake will, however, create CMakeCache.txt and CMakeFiles/* .") + message(STATUS " NOTE: You must delete CMakeCache.txt and CMakeFiles/* manually.") + message(STATUS "=======================================================================") + message("") + message(FATAL_ERROR "*** In-source builds are disabled, please read notes above! ***") +endif() + +####################################################################### # Set CMake minimum version first: must be set before `project()` ####################################################################### |
