[CMake] Output of ADD_CUSTOM_COMMAND generated multiple times

Martin Apel martin.apel at simpack.de
Tue Oct 7 04:22:10 EDT 2008


Hi all,

I'm experiencing the following problem with ADD_CUSTOM_COMMAND:
The commands defined for it are executed multiple times, if multiple
targets depend on it and I run a parallel make afterwards.
An example makes this easier to understand:

PROJECT(Test)
cmake_minimum_required(VERSION 2.6)

ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/a
                   COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/a)

ADD_CUSTOM_TARGET(b
                  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/b
                  DEPENDS ${CMAKE_BINARY_DIR}/a)
ADD_CUSTOM_TARGET(c
                  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/c
                  DEPENDS ${CMAKE_BINARY_DIR}/a)

ADD_CUSTOM_TARGET(world)
ADD_DEPENDENCIES(world b)
ADD_DEPENDENCIES(world c)


When running a "make -j2 world" afterwards, the following output appears:
[  0%] [  0%] Generating a
Generating a
[ 50%] [100%] Built target b
Built target c
[100%] Built target world

When doing a "make -j1 world", a is generated only once. From my
understanding a should only be generated once in the first case as well.
Am I misunderstanding anything or is this a bug in CMake? CMake version
is 2.6.2 on Linux.

Regards,

Martin

____________
Virus checked by G DATA AntiVirus
Version: AVF 19.91 from 06.10.2008




More information about the CMake mailing list