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
2025-03-30 22:37:42 +02:00
committed by GitHub
parent b41e066aa1
commit 8a7c9c971f
2 changed files with 5 additions and 1 deletions

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
#-------------------------------------------------------------------------------