[cmake-developers] Review Request: Topic ExternalProject-independent-step-targets
Daniele E. Domenichelli
daniele.domenichelli at gmail.com
Mon Dec 16 09:23:20 EST 2013
On 09/12/13 16:06, Brad King wrote:
> Can you reproduce the dependency ordering failure with a few simple
> add_custom_command and add_custom_target calls and no ExternalProject
> module? That will make it much easier to pin down, and the result
> can be added to the general test suite (e.g. CustomCommand test) too.
After some tests I managed to reproduce the behaviour in this test that
fails, both with ninja (always) and with make -j2 (only sometimes), but
I'm no longer sure if this is a bug or not.
---
cmake_minimum_required(VERSION 2.8)
##### Proj1 #####
add_custom_target(Proj1 ALL DEPENDS ${CMAKE_BINARY_DIR}/CMakeFiles/Proj1-stamp)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/CMakeFiles/Proj1-stamp
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/Proj1-file1
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/CMakeFiles/Proj1-stamp
)
##### Proj2 #####
add_custom_target(Proj2 ALL DEPENDS ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-stamp)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-stamp
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-stamp
)
##### Proj2-step #####
add_custom_command(APPEND
OUTPUT ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-stamp
DEPENDS ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-step-stamp
)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-step-stamp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/Proj1-file1 ${CMAKE_BINARY_DIR}/Proj2-file1
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-step-stamp
)
add_custom_target(Proj2-step
DEPENDS ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-step-stamp
)
##### Extra dependency #####
add_dependencies(Proj2-step Proj1)
---
The problem seems to be that the file level dependency is not set, if
I add:
add_custom_command(APPEND
OUTPUT ${CMAKE_BINARY_DIR}/CMakeFiles/Proj2-step-stamp
DEPENDS Proj1)
the dependency issue is fixed.
So maybe this is just a bug in this CMake code and not in CMake.
Nonetheless I think it should be possible to do something like
add_dependencies(Proj2-step Proj1) for targets created with ExternalProjects
without caring about file level dependencies... what do you think?
Maybe adding a function
ExternalProject_Add_Dependencies(name step targets)
that internally calls both add_dependencies and add_custom_command(APPEND)?
Cheers,
Daniele
More information about the cmake-developers
mailing list