Hi,
I would like to achieve the following:
- The default target builds all artifacts.
- 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:
- Use
EXCLUDE_FROM_ALL
for all test executables. This prevents install from building the tests, but the default target now doesn’t build tests. - 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?