# Help with CPack ignore regex

**URL:** https://discourse.cmake.org/t/help-with-cpack-ignore-regex/6283
**Category:** Usage
**Created:** [August 16, 2022, 1:45pm UTC](https://discourse.cmake.org/t/help-with-cpack-ignore-regex/6283 "2022-08-16T13:45:16Z")
**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: [August 16, 2022, 1:45pm UTC](https://discourse.cmake.org/t/help-with-cpack-ignore-regex/6283/1 "2022-08-16T13:45:16Z")

</div>

All,

I’m hoping for some help here. We recently found that we need to add some extra files to our `CPACK_SOURCE_IGNORE_FILES` and, well, I need help. I currently have:

```cmake
set(CPACK_SOURCE_IGNORE_FILES
  /.git/
  /.mepo/
  /build.*/
  /install.*/
)

```

but I’d like to add more now. For example, I’d like to ignore any `*.swp` files in any directory or that vim would make or maybe `*~` files from emacs.

So went to a subdirectory and did:

```auto
cp CMakeLists.txt CMakeLists.txt.swp

```

to create a dummy file and tried adding:

```cmake
  *.swp

```

but I got:

```auto
RegularExpression::compile(): ?+* follows nothing.
RegularExpression::compile(): Error in compile.

```

So, I look around the web and see that I maybe should use:

```auto
   \\\\.swp

```

and that does compile…but doesn’t seem to do what I want as the test `CMakeLists.txt.swp` file I made is still in the tarfile made by CPack.

So what is the right way to figure out these regexes?

Thanks,  
Matt

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [August 16, 2022, 9:12pm UTC](https://discourse.cmake.org/t/help-with-cpack-ignore-regex/6283/2 "2022-08-16T21:12:40Z")

</div>

Wouldn’t it make more sense to give CPack the ability to honor .git-ignore files?

Or use git to pack the source?

Also using CPack to package sources is quite inefficient as it copies to another directory first instead of directly into the archive.

---

<div class="post-metadata">

### Author: ![vdamewood](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/7ab992/32.png) [@vdamewood](https://discourse.cmake.org/u/vdamewood)
#### Post date: [August 16, 2022, 10:09pm UTC](https://discourse.cmake.org/t/help-with-cpack-ignore-regex/6283/3 "2022-08-16T22:09:37Z")

</div>

> [@mathomp4](#):
>
> ` *.swp`

This looks like glob, not a regex. Maybe you wan’t `.*\.swp`, instead.
