[CMake] Disabling INSTALL target for subdirectory
Milan Ziegler
milan at fastmail.com
Fri Feb 17 01:32:07 EST 2017
Hi Florent,
thank you so much. EXCLUDE_FROM_ALL does indeed have the effect of
ignoring any install() invocations from within the subdirectory. I
remember stumbling across this option, but from the docs I didn't get
the impression that this would affect the installation as well.
Maybe the documentation needs a few more words here.
>
> Also, 3rdparty libraries should be tagged like that anyway to be built
> only when they are used by the main targets.
Yes, this is a good idea.
Thanks again,
Milan
--
Milan Ziegler
milan at fastmail.com
On Thu, Feb 16, 2017, at 13:33, Florent Castelli wrote:
> 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" <milan at 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
>> milan at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170217/5e985b48/attachment.html>
More information about the CMake
mailing list