[CMake] ExternalProject_add combined with add_custom_command

Veljko Mihailovic shakal187 at gmail.com
Wed Mar 12 09:14:33 EDT 2014


Hi
In have two projects. One is the parent, the second one is the child. The
second one is the generator for the parent. I require to include the child
project inside the parent, build it and use the executable of the child to
generate files for the parent. I was able to include the child project and
build it in parent through ExternalProject_Add command. What I'm not able
to do is to use the executable from the child project and generate files
for the parent project. Can I get some help with this? An working example
combining these two functionalities? Here is how I do it:

include(ExternalProject)

set(code_gen_PREFIX "${PROJECT_SOURCE_DIR}/code_gen")
set(code_gen_SVN_URL "*/url/to/child/proj/*")
set(code_gen_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release;
-DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}*/bins/*)

ExternalProject_Add(code_generator
PREFIX ${code_gen_PREFIX}
SVN_REPOSITORY ${code_gen_SVN_URL}
SVN_USERNAME ${code_gen_SVN_USER}
SVN_PASSWORD ${code_gen_SVN_PASS}
CMAKE_ARGS ${code_gen_CMAKE_ARGS}
STAMP_DIR ${code_gen_PREFIX}
)


add_executable(code_generator IMPORTED GLOBAL)
set_property(TARGET code_generator PROPERTY IMPORTED_LOCATION
"${PROJECT_SOURCE_DIR}*/bins/*")

add_custom_command(
OUTPUT file1 file2 file3 file4
COMMAND code_generator args_for_code_generator_app
COMMAND code_generator args_for_code_generator_app
)
Some notes:
Each call of the command outputs two files, that's why I have 4 files for
the output.
The step with ExternalProject_Add is working, all the variables are
properly set.
${PROJECT_SOURCE_DIR}*/bins/* is good, I checked it multiple times and
executable is on this path.
I get this type of error
*/bin/sh: 1:${PROJECT_SOURCE_DIR}/bins/*: Permission denied
Both of the projects are CMake projects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140312/191fdfbd/attachment-0001.html>


More information about the CMake mailing list