# Help with CPack for excluding some directories matching...but not all

**URL:** https://discourse.cmake.org/t/help-with-cpack-for-excluding-some-directories-matching-but-not-all/7590
**Category:** Usage
**Created:** [March 2, 2023, 6:18pm UTC](https://discourse.cmake.org/t/help-with-cpack-for-excluding-some-directories-matching-but-not-all/7590 "2023-03-02T18:18:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mathomp4](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mathomp4/32/176_2.png) [@mathomp4](https://discourse.cmake.org/u/mathomp4)
#### Post date: [March 2, 2023, 6:18pm UTC](https://discourse.cmake.org/t/help-with-cpack-for-excluding-some-directories-matching-but-not-all/7590/1 "2023-03-02T18:18:06Z")

</div>

All,

I need some help. I’ve already asked for CPack help here before, but I find I need more. Namely, I currently have this:

```cmake
set(CPACK_SOURCE_IGNORE_FILES
  /.git/
  /.mepo/
  /build.*/
  /install.*/
  /CVS/
  .\*.swp
  .\*.swo
  .\*~
  .\*\#
  \.DS_Store
)

```

set in my project so I can make tarfiles of source code but not include any build or install or .git directories, etc.

And it works well, until recently a user found an issue. Namely, he didn’t name his build and install directories like `build-foo/` and `install-foo/` but rather `foo-build/` and `foo-install/` and he found he was making _enormous_ tarfiles.

Now I could just ban anything with the word “build” in it, say, but my code has `ecbuild/` as a subdirectory that I want to capture in the tarfile.

So, I’m wondering, is there anyway to say “exclude all directories with `build` in the name, but specifically include `ecbuild`”? My guess [from the docs](https://cmake.org/cmake/help/latest/module/CPack.html) is “probably not”, but maybe the gurus here can help!

Thanks,  
Matt

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 4, 2023, 9:20pm UTC](https://discourse.cmake.org/t/help-with-cpack-for-excluding-some-directories-matching-but-not-all/7590/2 "2023-03-04T21:20:41Z")

</div>

Would it be possible to configure the file containing the `IGNORE_FILES` to include the build directory name explicitly? Or have it include a configured file in some way.

---

<div class="post-metadata">

### Author: ![mathomp4](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mathomp4/32/176_2.png) [@mathomp4](https://discourse.cmake.org/u/mathomp4)
#### Post date: [March 5, 2023, 4:51pm UTC](https://discourse.cmake.org/t/help-with-cpack-for-excluding-some-directories-matching-but-not-all/7590/3 "2023-03-05T16:51:31Z")

</div>

Hmm. Interesting thought. At the moment, my cpack code is in a module pulled in with a simple `include()` call in the module path, but I suppose I could `configure_file()` it and then include it from the `build` directory.
