# Creating two separate packages with the same binary using components

**URL:** <https://discourse.cmake.org/t/creating-two-separate-packages-with-the-same-binary-using-components/13971>\
**Category:** Code\
**Created:** [April 23, 2025, 2:40pm UTC](https://discourse.cmake.org/t/creating-two-separate-packages-with-the-same-binary-using-components/13971 "2025-04-23T14:40:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aludeck12](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@aludeck12](https://discourse.cmake.org/u/aludeck12)\
**Post date:** [April 23, 2025, 2:40pm UTC](https://discourse.cmake.org/t/creating-two-separate-packages-with-the-same-binary-using-components/13971/1 "2025-04-23T14:40:38Z")

</div>

Hello,

I am very new to packaging targets and files using components.  
My goal was that I want 2 different packages, that contain the same binary each and different files and based on which package is installed, the binary will read the file that is available to it.  
I found the solution below that works and does what I need and what I expect.

```auto
cmake_minimum_required(VERSION 3.11.0)

project(TestApp VERSION 1.0.0 LANGUAGES CXX)

add_executable(${PROJECT_NAME} main.cpp)

install(TARGETS ${PROJECT_NAME}
    RUNTIME 
        DESTINATION bin/dev
        COMPONENT DEV
)

install(FILES
    ${CMAKE_SOURCE_DIR}/numbers_dev.txt
        DESTINATION bin/dev
        COMPONENT DEV
)

install(TARGETS ${PROJECT_NAME}
    RUNTIME 
        DESTINATION bin/default
        COMPONENT DEFAULT
)

install(FILES
    ${CMAKE_SOURCE_DIR}/numbers_default.txt
        DESTINATION bin/default
        COMPONENT DEFAULT
)

set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_GENERATOR "TGZ")
set(CPACK_ARCHIVE_DEV_FILE_NAME "dev")
set(CPACK_ARCHIVE_DEFAULT_FILE_NAME "default")
set(CPACK_COMPONENTS_ALL "")
list(APPEND CPACK_COMPONENTS_ALL "DEV" "DEFAULT")

include(CPack)

```

I would like to ask if there could be better/another solution in CMake to what I want to do ?

As far as I know I cannot assign 2 component names like this:

```auto
install(TARGETS ${PROJECT_NAME}
    RUNTIME 
        DESTINATION bin/dev
        COMPONENT DEV DEFAULT # cmake error
)

```

I also know that something like this would not work either:

```auto
install(TARGETS ${PROJECT_NAME}
    RUNTIME 
        DESTINATION bin/dev
        COMPONENT DEV
    RUNTIME 
        DESTINATION bin/default
        COMPONENT DEFAULT # this one makes the first one obsolete
)

```
