# Installing CMake target containing C++20-Module without installing the compiled artifact

**URL:** <https://discourse.cmake.org/t/installing-cmake-target-containing-c-20-module-without-installing-the-compiled-artifact/13928>\
**Category:** Code\
**Created:** [April 14, 2025, 1:44pm UTC](https://discourse.cmake.org/t/installing-cmake-target-containing-c-20-module-without-installing-the-compiled-artifact/13928 "2025-04-14T13:44:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![M2-TE](https://discourse.cmake.org/user_avatar/discourse.cmake.org/m2-te/32/5504_2.png) [@M2-TE](https://discourse.cmake.org/u/M2-TE)\
**Post date:** [April 14, 2025, 1:44pm UTC](https://discourse.cmake.org/t/installing-cmake-target-containing-c-20-module-without-installing-the-compiled-artifact/13928/1 "2025-04-14T13:44:18Z")

</div>

Given the target `moduletarget`

```cmake
add_library(moduletarget)
target_sources(moduletarget PUBLIC
    FILE_SET module
    TYPE CXX_MODULES
    FILES "some/module/source.cppm")

```

installing the target will also install the `libmoduletarget.a` artifact.

Given the still rather unstable nature of modules, I would prefer to instead just install the `.cppm` file as normal and provide the `moduletarget` target without installing the static/shared artifact, so that the consumer compiles the `.cppm` themselves.

I did not find a way to have the install omit the `ARCHIVE` or `RUNTIME` artifacts, so would this be possible, or rather, is there a better approach?

---

<div class="post-metadata">

**Author:** ![M2-TE](https://discourse.cmake.org/user_avatar/discourse.cmake.org/m2-te/32/5504_2.png) [@M2-TE](https://discourse.cmake.org/u/M2-TE)\
**Post date:** [April 23, 2025, 11:16am UTC](https://discourse.cmake.org/t/installing-cmake-target-containing-c-20-module-without-installing-the-compiled-artifact/13928/2 "2025-04-23T11:16:00Z")

</div>

For those stumbling upon this, the solution was to make it an [OBJECT](https://cmake.org/cmake/help/latest/command/add_library.html#object-libraries) library, like so:

```cmake
add_library(moduletarget OBJECT)
target_sources(moduletarget PUBLIC ...)

```
