[CMake] Help with custom targets

Ulrik Mikaelsson ulrik.mikaelsson at gmail.com
Sat Mar 3 12:37:32 EST 2007


Yes, that seems to work, with the unfortunate side-effect of having my
binary application unnecessarily re-built every time I change my EDC,
which might not be a big problem, but a bit annoying.

Is there no way of specifying an equivalent of:
all: showroom data/interface.edj

showroom: main.c
    $(CC) -o showroom main.c

data/interface.edj: data/interface.edc
     edje_cc data/interface.edc data/interface.edj

That is, what I'd really want would be to define a custom target,
linked to a file with dependencies, and a rule to build the target if
the dependencies are newer than the target file. Pretty much the
standard use-case of make, but preferably without hooking up the
dependency-chain on a certain executable or library. In the end, I
would like to be able to run "make data/interface.edj".

Any ideas?

Regards
/ Ulrik

On 3/3/07, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> Alan W. Irwin wrote:
> > On 2007-03-03 16:10+0100 Ulrik Mikaelsson wrote:
> >
> >> My problem right now is that I would like to define my edje-resources
> >> as special targets, and have them depend on their respective
> >> source-files, but I haven't managed to make them behave as I want.
> >>
> >> I've come pretty close using the ADD_CUSTOM_COMMAND() in OUTPUT mode,
> >> but for some reason I have not been able to make the dependencies work
> >> such that when I update the source-files, and run make, the compiled
> >> resources are updated.
> >
> > My experience is custom command dependencies generally work if you
> > specify
> > full pathnames and you always have a custom target file-depending on the
> > OUTPUT of a custom command.
> >
> > Here is one CMake fragment illustrating a working example:
> >
> > add_executable(plhershey-unicode-gen ${plhershey-unicode-gen_SRCS})
> >
> > add_custom_command(
> > OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h
> > COMMAND ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode-gen${EXEEXT}
> > ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv
> > plhershey-unicode.h
> > DEPENDS
> > ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode-gen${EXEEXT}
> > ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv
> > )
> >
> > add_custom_target(
> > plhershey-unicode.h_built
> > DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h
> >
> > This dependency chain was complicated by the fact that my custom command
> > file-depended on the results of add_executable, and my custom target was
> > target-depended by an add_library in another directory.  But this
> > dependency
> > chain works as expected with plhershey-unicode.h being generated only
> > when
> > needed (which is important because an earlier incorrect version of this
> > generated the header every time which lead to an expensive library
> > rebuild
> > every time).
> >
> > If this pattern of working dependencies does not give you any helpful
> > ideas,
> > could you give a simple example of the dependency problem you are
> > encountering?
> >
>
> Basically, you have to make sure that the output of the custom command
> is in the input of some target that will get built.   It does not have
> to be a custom_target.  If you create a .h file, just make sure you add
> the .h file to the sources of an executable or library.   There are
> several entries about this in the wiki.
>
> -Bill
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list