# Exclude build directories from cpack source package

**URL:** https://discourse.cmake.org/t/exclude-build-directories-from-cpack-source-package/423
**Category:** Usage
**Tags:** os:linux
**Created:** [December 20, 2019, 8:56pm UTC](https://discourse.cmake.org/t/exclude-build-directories-from-cpack-source-package/423 "2019-12-20T20:56:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Acsor](https://discourse.cmake.org/user_avatar/discourse.cmake.org/acsor/32/263_2.png) [@Acsor](https://discourse.cmake.org/u/Acsor)
#### Post date: [December 20, 2019, 8:56pm UTC](https://discourse.cmake.org/t/exclude-build-directories-from-cpack-source-package/423/1 "2019-12-20T20:56:21Z")

</div>

I have a basic CMake setup for a project whose sources I want to distribute as an archive. My current CPack config. is as follows

```cmake
include(InstallRequiredSystemLibraries)

set(CPACK_PACKAGE_NAME bikaya)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md)
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_VERSION_MINOR})
set(CPACK_PACKAGE_DESCRIPTION ${PROJECT_DESCRIPTION})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md)

include(CPack)

```

My first effective run of the `cpack` command was

```bash
$ cd clion-build-uarm
$ cpack
$ cpack -G TGZ --config CPackSourceConfig.cmake

```

resulting in a `bikaya-0.1.0-Source.tar.gz` file. Upon inspecting that file, however, I noted that it contained all the stuff in the `clion-build-arm/` directory – which I obviously am not intersted in, since this is just a _source_ package.

How do I exclude unwanted files/directories?

---

<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: [February 15, 2020, 11:58pm UTC](https://discourse.cmake.org/t/exclude-build-directories-from-cpack-source-package/423/2 "2020-02-15T23:58:17Z")

</div>

Doing an out-of-source build seems to be the way to go here. Alternatively, you may add your build directory to the [`CPACK_SOURCE_IGNORE_FILES` variable](https://cmake.org/cmake/help/latest/module/CPack.html#variables-for-source-package-generators).
