libftdi Archives

Subject: [PATCH 3/4] CMakeLists.txt: ignore out-of-source build folder

From: yegorslists@xxxxxxxxxxxxxx
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: thomas.jarosch@xxxxxxxxxxxxx, Yegor Yefremov <yegorslists@xxxxxxxxxxxxxx>
Date: Wed, 2 Apr 2025 10:12:36 +0200
From: Yegor Yefremov <yegorslists@xxxxxxxxxxxxxx>

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/
---
 .gitignore     | 1 -
 CMakeLists.txt | 5 +++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index b652e9f..34f3852 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,6 @@
 .deps/
 .libs/
 .kdev4/
-build/
 
 # kdevelop
 *.kdevelop.pcs
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c5dbc74..3d1b774 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,11 @@ set(CMAKE_COLOR_MAKEFILE ON)
 
 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
+if(NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
+  # Auto-create a .gitignore in the out-of-source build directory.
+  file(GENERATE OUTPUT .gitignore CONTENT "*")
+endif()
+
 add_definitions(-Wall)
 
 include(CMakeOptions.txt)
-- 
2.34.1


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread