From 21a894b3c47e510a3342917bc04ec945aff2343d Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 11 Mar 2021 08:41:56 -0500 Subject: [PATCH] Use CMake to ignore build and install directories --- .gitignore | 3 --- CMakeLists.txt | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1ef81ae5..bbb5eb68 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,6 @@ /@cmake/ /@modules/ /@env/ -/BUILD/ -/build*/ -/install*/ /.mepo/ parallel_build.o* log.* diff --git a/CMakeLists.txt b/CMakeLists.txt index 58c18aff..b6103aee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,3 +44,14 @@ include_directories(${MPI_Fortran_INCLUDE_PATH}) add_subdirectory (@env) add_subdirectory (src) +# https://www.scivision.dev/cmake-auto-gitignore-build-dir/ +# --- auto-ignore build directory +if(NOT EXISTS ${PROJECT_BINARY_DIR}/.gitignore) + file(WRITE ${PROJECT_BINARY_DIR}/.gitignore "*") +endif() + +# Piggyback that file into install +install( + FILES ${PROJECT_BINARY_DIR}/.gitignore + DESTINATION ${CMAKE_INSTALL_PREFIX} + )