Hi,

I have a problem with ExternalProject and how to depend on that. I'm not
absolutely sure I got the CMakeLists.txt right, so I first ask here before
filing a bug report.

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. 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.

I've tested this with 2.8.2 and 2.8.3-rc2.

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 ===

Side note: I would have expected that CMAKE_INSTALL_PREFIX is set to
INSTALL_DIR if the external project is a cmake one.

Eike
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to