<div>You can use the COMPONENT option to install() for your own project and then select a component-based package if you are packaging with CPack. We currently do this with builds that incorporate other projects with add_subdirectory() similar to your case. </div><div><br></div><div>If you are using install as a build target (ie make install or equivalent), I don't think the above will help you. I don't recall if the EXCLUDE_FROM_ALL option to add_subdirectory() affects install or not. I believe there was some discussion about this in one of the mailing lists or gitlab issues recently, so maybe someone else can chime in to clarify this part. </div><div><br></div><div> <br><div class="gmail_quote"><div>On Thu, 16 Feb 2017 at 3:59 pm, Milan Ziegler <<a href="mailto:milan@fastmail.com">milan@fastmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="gmail_msg">
<br class="gmail_msg">
we are using the CMake install mechanism "install(...)" to copy all<br class="gmail_msg">
relevant files and target binaries of the product into the CMake install<br class="gmail_msg">
prefix folder, for further packaging. So far so good.<br class="gmail_msg">
<br class="gmail_msg">
We are also using several thirdparty libraries, hosting them inside our<br class="gmail_msg">
own repository and building them along with our own code, usually using<br class="gmail_msg">
add_subdirectory utilizing their native CMake buildsystem.<br class="gmail_msg">
<br class="gmail_msg">
Turns out, other developers also like the CMake install mechanism.<br class="gmail_msg">
<br class="gmail_msg">
So now the INSTALL target of our whole project also installs thirdparty<br class="gmail_msg">
components, which we do not want to deliver with our own product (think<br class="gmail_msg">
static libraries, which are already linked into our executable).<br class="gmail_msg">
<br class="gmail_msg">
After a lot of googling, here's my question: Is there a clean way to<br class="gmail_msg">
disable the install target for a subdirectory _without_ also disabling<br class="gmail_msg">
it completely for the remaining project?<br class="gmail_msg">
<br class="gmail_msg">
What we already tried:<br class="gmail_msg">
* Setting CMAKE_INSTALL_PREFIX to a temporary directory for the<br class="gmail_msg">
subdirectory (doesn't work)<br class="gmail_msg">
* "function(install) endfunction()" to disable the install function for<br class="gmail_msg">
the subdirectory (breaks CMake in hilarious ways)<br class="gmail_msg">
<br class="gmail_msg">
What we now do:<br class="gmail_msg">
Using a custom target, we patch the cmake_install.cmake files in the<br class="gmail_msg">
build directories before installing (works, but it's an  abomination of<br class="gmail_msg">
a hack)<br class="gmail_msg">
<br class="gmail_msg">
Any help? I think it's a valid usecase for CMake but there doesn't seem<br class="gmail_msg">
to be an easy way to do it.<br class="gmail_msg">
<br class="gmail_msg">
We are using CMake 3.5.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Thank you :)<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
  Milan<br class="gmail_msg">
  <a href="mailto:milan@fastmail.com" class="gmail_msg" target="_blank">milan@fastmail.com</a><br class="gmail_msg">
--<br class="gmail_msg">
<br class="gmail_msg">
Powered by <a href="http://www.kitware.com" rel="noreferrer" class="gmail_msg" target="_blank">www.kitware.com</a><br class="gmail_msg">
<br class="gmail_msg">
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" class="gmail_msg" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br class="gmail_msg">
<br class="gmail_msg">
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br class="gmail_msg">
<br class="gmail_msg">
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" class="gmail_msg" target="_blank">http://cmake.org/cmake/help/support.html</a><br class="gmail_msg">
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" class="gmail_msg" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br class="gmail_msg">
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" class="gmail_msg" target="_blank">http://cmake.org/cmake/help/training.html</a><br class="gmail_msg">
<br class="gmail_msg">
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" class="gmail_msg" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br class="gmail_msg">
<br class="gmail_msg">
Follow this link to subscribe/unsubscribe:<br class="gmail_msg">
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" class="gmail_msg" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a></blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>