[CMake] Why is this custom command run twice?

Eric Noulard eric.noulard at gmail.com
Fri Apr 23 14:19:55 EDT 2010


2010/4/23 <Aaron_Wright at selinc.com>
>
> Is there no interest in this differing behavior between Linux and Windows?

I'm pretty sure there should be :-)
But may be not as urgent as you wish.

> I'm a little worried that CMake doesn't produce the same results in both situations. Aren't those kind of things bugs?

Looks like a bug. However something is puzzling me.

What does this intend to do:

ADD_CUSTOM_TARGET(
 ${PROJECT_NAME}
  DEPENDS "${PROJECT_BINARY_DIR}/generated_used.stamp")

Do you really intend to name the target with the name of the project ?
If you do,  why ?
I think you should not do that (I'm not sure it's forbidden though)

I think you should pick up a different name say ${PROJECT_NAME}_genme
and if you want this particular target to be generated every time you build
the project then use the ALL argument. cf ADD_CUSTOM_TARGET documentation.

Then this particular target will ALWAYS be run but its dependency target won't
unless it is out of date.

Note that if your generated_used file is to be used for the build of
another target
(lib or executable) then may be you should use the following signature:

add_custom_command(TARGET target
                            PRE_BUILD | PRE_LINK | POST_BUILD
                            COMMAND command1 [ARGS] [args1...]
                            [COMMAND command2 [ARGS] [args2...] ...]
                            [WORKING_DIRECTORY dir]
                            [COMMENT comment] [VERBATIM])

Since PRE_BUILD seems to be only supported on Visual 7 and up I would not
rely on it for a Unix build.

>
> If no one knows the answer off the top of their head, are there some debugging tips or avenues of investigation anyone could share?

May be diving into the generated file for Visual Studio and trying to find
some duplicate name for this particular target? Just a guess I'm
really not a MSVC guy.


--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list