# Install without building tests

**URL:** <https://discourse.cmake.org/t/install-without-building-tests/10336>\
**Category:** Code\
**Created:** [March 9, 2024, 4:08pm UTC](https://discourse.cmake.org/t/install-without-building-tests/10336 "2024-03-09T16:08:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![geertj](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/a698b9/32.png) [@geertj](https://discourse.cmake.org/u/geertj)\
**Post date:** [March 9, 2024, 4:08pm UTC](https://discourse.cmake.org/t/install-without-building-tests/10336/1 "2024-03-09T16:08:26Z")

</div>

Hi,

I would like to achieve the following:

1. The default target builds all artifacts.
2. The “install” target only builds the artifacts that it installs.

My use case that I want to improve “install” times by not building tests, which we do not install, while still having the default target build everything, which is what our devs have come to expect. We could change the expectations on the latter, but that would not be my preference.

I have tried two approaches. Both of them are close but none do exactly what I’d like:

1. Use `EXCLUDE_FROM_ALL` for all test executables. This prevents install from building the tests, but the default target now doesn’t build tests.
2. Set `CMAKE_SKIP_INSTALL_ALL_DEPENDENCY`, and then add a custom “custom-install” target that depends on the installable artifacts, and runs a COMMAND that does `${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR}`. This keeps the default target building everything, build my install target is now named “custom-install” instead of “install”.

To me, the fundamental issue appears that install depends on targets that are not installed, which seems wrong? If that’s by design, is there another way to achieve what I want?

---

<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:** [April 10, 2024, 9:45pm UTC](https://discourse.cmake.org/t/install-without-building-tests/10336/2 "2024-04-10T21:45:30Z")

</div>

It’s a long-standing issue that `install` is not hooked up to what is installed. I have ideas on how it can be fixed based on other in-progress developments, but there’s no roadmap for anything handling this specifically at the moment.

---

<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:** [October 26, 2024, 2:57am UTC](https://discourse.cmake.org/t/install-without-building-tests/10336/3 "2024-10-26T02:57:42Z")

</div>

> [@geertj](#):
>
> I you use  
> `EXCLUDE_FROM_ALL`

What happens when doing **ctest —build-and-test** … ?
