# install - wrong files, wrong location.

**URL:** https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481
**Category:** Code
**Created:** [August 19, 2024, 3:04am UTC](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481 "2024-08-19T03:04:27Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![duaneellis\_inno](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/f04885/32.png) [@duaneellis\_inno](https://discourse.cmake.org/u/duaneellis_inno)
#### Post date: [August 19, 2024, 3:04am UTC](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481/1 "2024-08-19T03:04:27Z")

</div>

Is there a way to control the list of files installed? when “make install” occurs?

A) I have an embedded target - so nothing really gets installed.  
Instead my CI/CD process says: put all important files in THIS directory.

B) I know that name of files - these are hex files, elf files and a few others  
I have them in a LIST called: ARTIFACTS\_LIST -

C) As a post build step - I need to “quasi-install” them  
but the CMAKE install process thinks things go in: /usr/local/whatever.

No No and Absolutly No CMAKE has it wrong very wrong.

The files go where I want them to go and nowhere else.  
and there shall be nothing other then the files I specify in that directory.

====  
stated differently:

1. I create a ELF executable as the main build target.
2. From that ELF - I create a bin, a hex file, a C and H file, a symbol table, a map file etc.
3. Some are created via a post build event (I have 5 steps) post elf file

I have the complete lists of files that need to be pushed to the ARTIFACTS directory  
how do I do that.?

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [August 19, 2024, 4:52am UTC](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481/2 "2024-08-19T04:52:14Z")

</div>

CMake install what and to the destination directory you are able to control in your project files and by using the right command line options. See too [CMAKE\_SKIP\_INSTALL\_RULES](https://cmake.org/cmake/help/latest/variable/CMAKE_SKIP_INSTALL_RULES.html#cmake-skip-install-rules)

i.e.:

```bash
cmake -G Ninja -B build -S . -D CMAKE_INSTALL_PREFIX=/tmp/test

```

and use COMPONENT option in your install configuration, i.e:

```cmake
install(TARGETS MyShared MyStatic
    RUNTIME
        DESTINATION ${CMAKE_INSTALL_BINDIR}
        COMPONENT MyProj_Runtime
    LIBRARY
        DESTINATION ${CMAKE_INSTALL_LIBDIR}
        COMPONENT MyProj_Runtime
        NAMELINK_COMPONENT MyProj_Development
    ARCHIVE
        DESTINATION ${CMAKE_INSTALL_LIBDIR}
        COMPONENT MyProj_Development
)

```

---

<div class="post-metadata">

### Author: ![duaneellis\_inno](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/f04885/32.png) [@duaneellis\_inno](https://discourse.cmake.org/u/duaneellis_inno)
#### Post date: [August 19, 2024, 3:55pm UTC](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481/3 "2024-08-19T15:55:14Z")

</div>

Ok - I see how to specify the INSTALL directory.  
And how to disable generation of the cmake install cmake file

But how do I control _WHAT_ files are installed and/or NOT placed in that directory?

aka: I have a list of files that should be installed and I only want that list of files installed. (copied to the installation directory)

---

<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 19, 2024, 6:40pm UTC](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481/4 "2024-08-19T18:40:22Z")

</div>

Well, just the things that are defined by INSTALL() commands are installed.

You define the relative or absolute destinations.

You can specify an explicit base install directory if you choose the usual preferred relative destinations.

You can define components (groups of installed files).

All of this has to be explicitly written by you. And if you think differently, you can just not use it but your own scripts instead.

So what’s the matter?

---

<div class="post-metadata">

### Author: ![duaneellis\_inno](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/f04885/32.png) [@duaneellis\_inno](https://discourse.cmake.org/u/duaneellis_inno)
#### Post date: [August 19, 2024, 8:43pm UTC](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481/5 "2024-08-19T20:43:53Z")

</div>

> > so what’s the matter?

> > You can define components (groups of installed files).

How do I do that?

I have a list of files created with list(APPEND …)  
Those are the only files that should be placed in the install directory.  
No other files. No sub directories… etc

In bash, it is as simple as:  
for X in LIST\_OF\_FILES  
do  
cp $X ${INSTALL\_DIR}  
done

CMAKE makes this sort of very confusing on how to accomplish In my opinion a simple task.  
Nothing is straight forward.

---

<div class="post-metadata">

### Author: ![retif](https://discourse.cmake.org/user_avatar/discourse.cmake.org/retif/32/1776_2.png) [@retif](https://discourse.cmake.org/u/retif)
#### Post date: [August 19, 2024, 9:10pm UTC](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481/6 "2024-08-19T21:10:11Z")

</div>

> control the list of files installed  
> I have them in a LIST called: ARTIFACTS\_LIST  
> Those are the only files that should be placed in the install directory  
> No other files  
> No sub directories

Then [do so](https://cmake.org/cmake/help/latest/command/install.html#files), why don’t you:

```cmake
list(APPEND ARTIFACTS_LIST
    "${CMAKE_CURRENT_SOURCE_DIR}/etc/1.txt"
    "${CMAKE_CURRENT_SOURCE_DIR}/etc/2.txt"
    "${CMAKE_CURRENT_SOURCE_DIR}/etc/3.txt"
)

install(
    FILES ${ARTIFACTS_LIST}
    DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/install" # or "${CMAKE_INSTALL_PREFIX}" # or "/path/to/wherever/is/your/install"
)

```

> Instead my CI/CD process says: put all important files in THIS directory

“What the hell is even that”. ©
