[CMake] Yet another install() vs. exclude_from_all thread

Hendrik Sattler post at hendrik-sattler.de
Tue Apr 27 10:21:29 EDT 2010


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.

BTW: "make install bar" shows the behaviour but maybe the OP just wanted 
"make bar install" instead ;)
Or better "make bar && make install" when having MAKEFLAGS set to -j2.

HS


More information about the CMake mailing list