Use add_subdirectory(...  EXCLUDE_FROM_ALL) to prevent anything in there to
be installed by default.
I had the issue in one project and it did fix it for us.

Also, 3rdparty libraries should be tagged like that anyway to be built only
when they are used by the main targets.

/Florent

On Feb 16, 2017 07:59, "Milan Ziegler" <mi...@fastmail.com> wrote:

> Hi,
>
> we are using the CMake install mechanism "install(...)" to copy all
> relevant files and target binaries of the product into the CMake install
> prefix folder, for further packaging. So far so good.
>
> We are also using several thirdparty libraries, hosting them inside our
> own repository and building them along with our own code, usually using
> add_subdirectory utilizing their native CMake buildsystem.
>
> Turns out, other developers also like the CMake install mechanism.
>
> So now the INSTALL target of our whole project also installs thirdparty
> components, which we do not want to deliver with our own product (think
> static libraries, which are already linked into our executable).
>
> After a lot of googling, here's my question: Is there a clean way to
> disable the install target for a subdirectory _without_ also disabling
> it completely for the remaining project?
>
> What we already tried:
> * Setting CMAKE_INSTALL_PREFIX to a temporary directory for the
> subdirectory (doesn't work)
> * "function(install) endfunction()" to disable the install function for
> the subdirectory (breaks CMake in hilarious ways)
>
> What we now do:
> Using a custom target, we patch the cmake_install.cmake files in the
> build directories before installing (works, but it's an  abomination of
> a hack)
>
> Any help? I think it's a valid usecase for CMake but there doesn't seem
> to be an easy way to do it.
>
> We are using CMake 3.5.
>
>
> Thank you :)
>
> --
>   Milan
>   mi...@fastmail.com
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to