[cmake-developers] [CMake 0011332]: No dependency from ADD_CUSTOM_COMMAND to external project

Mantis Bug Tracker mantis at public.kitware.com
Tue Oct 19 06:55:23 EDT 2010


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=11332 
====================================================================== 
Reported By:                Rolf Eike Beer
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   11332
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2010-10-19 06:55 EDT
Last Modified:              2010-10-19 06:55 EDT
====================================================================== 
Summary:                    No dependency from ADD_CUSTOM_COMMAND to external
project
Description: 
The idea is like this: we have an project that generates a couple of
files. In a special configuration of another project we need those files
as input for a special build step. Those step will take those files,
mangle them and will generate a source file at the end. I simulate this by
a simple copy below. This is then added as usual to a library (in my
example below to a executable, but that doesn't matter). When I run the
example below I get:

[ 80%] Built target Subdir_Build
make[2]: *** No rule to make target `Subdir_Build', needed by `main.c'. 
Stop.

The project "Subdir_Build" indeed exists, as "make Subdir_Build" runs
fine. And it looks for me as it is properly build before the target
depending on it. I have found no way to set a dependency on the external
project (tried ADD_CUSTOM_COMMAND(DEPENDS), ADD_DEPENDENCIES, and
SET_SOURCE_FILES_PROPERTIES). If CMake can't do this it should give at
least an error at CMake time.

Put this into CMakeLists.txt
=== snip ===
PROJECT(MaindirThing C)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2)

INCLUDE(ExternalProject)

ExternalProject_Add(Subdir_Build
                PREFIX "${CMAKE_CURRENT_BINARY_DIR}/build_subdir"
                SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/subdir"
                CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/build_subdir/install"
                INSTALL_DIR
"${CMAKE_CURRENT_BINARY_DIR}/build_subdir/install"
)

ADD_CUSTOM_COMMAND(
        OUTPUT "main.c"
        COMMAND ${CMAKE_COMMAND}
        ARGS -E copy ${CMAKE_CURRENT_BINARY_DIR}/build_subdir/install/foo
${CMAKE_CURRENT_BINARY_DIR}/main.c
        DEPENDS Subdir_Build
)

ADD_EXECUTABLE(simple_exe main.c)
=== snap ===

And this goes to subdir/CMakeLists.txt
=== snip ===
PROJECT(SubdirThing NONE)

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/foo_file "int main(void)\n{\n 
return 0;\n}\n")

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/foo_file DESTINATION .)
=== snap ===

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-10-19 06:55 Rolf Eike Beer New Issue                                    
======================================================================



More information about the cmake-developers mailing list