build: ignore out-of-source build folder #33191

Create a .gitignore file inside a build folder. This way this folder
will be ignored by git and hence, no entry in the root .gitignore is
required.

For more information see this post:
https://www.scivision.dev/cmake-auto-gitignore-build-dir/
This commit is contained in:
Yegor Yefremov authored and GitHub committed 2025-03-30 13:37:42 -07:00
1 parent b41e066aa1
commit 8a7c9c971f
2 files changed
+5 -1

No files matched your search

-1
View File
@@ -10,7 +10,6 @@ compile_commands.json
/.idea/
# Build/deps dir
/build/
/.deps/
/tmp/
/.clangd/
+5
View File
@@ -35,6 +35,11 @@ include(InstallHelpers)
include(PreventInTreeBuilds)
include(Util)
if(NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# Auto-create a .gitignore in the specified "build" directory.
file(GENERATE OUTPUT .gitignore CONTENT "*")
endif()
#-------------------------------------------------------------------------------
# User settings
#-------------------------------------------------------------------------------