Hi,
at our company we encountered the following problem. If we try to package our software using cpack, all targets in the CMakeLists.txt get build before the actual packaging. This however takes a very long time because unit tests and other services, which are not part of the package, get build as well.
How can we disable this behavior?
Plus, in any case, which of our executable gets part of the package? Only these with install instructions, or everything?
make package -j works perfectly fine for me… Anyways. I’m not sure if CPack is doing anything as it doesn’t print progress. Maybe it’s building something, but on one core this might take several hours.
Any other ideas besides EXCLUDE_FROM_ALL?
make package -j is performing the build in parallel. The actual package step can’t be parallelized, because it uses the cmake_install.cmake file, which runs serially.
Ah okay. So what I would like then is a parallel build, but with only the targets which are needed for the package. For example, unit tests should be skipped. The result should then be packaged for release.
Then after that, I don’t know the layout of your project but in my usual layout sources for unit tests are in a separate directory so going in ‘tests’ subdir is only done if(NOT DISABLE_TESTS) i.e.
cpack internally runs install before building the package so if any target is not installed it won’t be packaged either. This is usually the case of unit test executable and any generator tool built & used in the build for example.
Sounds good, but can cmake/cpack deduce these targets for me? I mostly call install with TARGETS option, so these dependencies should be clear for cmake/cpack.