[CMake] Yet another install() vs. exclude_from_all thread
Michael Hertling
mhertling at online.de
Tue Apr 27 19:38:42 EDT 2010
On 04/27/2010 04:21 PM, Hendrik Sattler wrote:
> Am Dienstag 27 April 2010 14:42:18 schrieb Michael Hertling:
>> On 04/27/2010 10:31 AM, Daniel Hornung wrote:
>>> On 2010-04-27 9:24, Daniel Hornung wrote:
>>>> And indeed "make install
>>>> ${some_name}" compiles those targets fine but does not install them.
>>>
>>> Addendum: I just found that those targets are only installed if they
>>> exist already when the "all" target is being installed (which is usually
>>> before they are built). So doing "make install ${some_name}" twice may
>>> be a workaround, albeit an undefined one.
>>
>> Are you sure this behaviour isn't the expected one?
>>
>> "make install" w.r.t. targets means:
>>
>> 1) Build any target that "install" depends on, especially "all",
>> but right not the excluded-from-all targets, and afterwards,
>> 2) install any target which is scheduled for installation by
>> INSTALL(TARGET ...) *and* already built; see "OPTIONAL".
>
> $ cmake ..
> -- The C compiler identification is GNU
> -- Check for working C compiler: /usr/bin/gcc
> -- Check for working C compiler: /usr/bin/gcc -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Configuring done
> WARNING: Target "bar" has EXCLUDE_FROM_ALL set and will not be built by
> default but an install rule has been provided for it. CMake does not define
> behavior for this case.
> -- Generating done
> -- Build files have been written to: ...
>
> $ cat ../CMakeLists.txt
> cmake_minimum_required(VERSION 2.8)
> project(foo C)
> add_executable(bar EXCLUDE_FROM_ALL bar.c)
> install(TARGETS bar DESTINATION bin OPTIONAL)
>
> Maybe CMake _should_ define the obvious behaviour and get rid of this message.
Indeed, the term "CMake does not define behavior for this case." is a
little irritating. From my experience, CMake behaves reasonably w.r.t
INSTALL(TARGET ... OPTIONAL ...), but nevertheless, I'd agree with:
<http://www.mail-archive.com/cmake@cmake.org/msg14998.html>
<http://www.mail-archive.com/cmake@cmake.org/msg14999.html>
One should really consider to do such optional stuff when running CMake
instead of delegating it to Make with its far less sophisticated means.
> BTW: "make install bar" shows the behaviour but maybe the OP just wanted
> "make bar install" instead ;)
Most likely. Here, my intention was just to point out that Make has no
idea of "installing a target" or the like, but solely of building them.
> Or better "make bar && make install" when having MAKEFLAGS set to -j2.
Yes, an implicit dependency easy to miss, though quite obvious.
Regards,
Michael
More information about the CMake
mailing list