On Sat, Mar 28, 2009 at 12:16:21AM -0600, James Bigler wrote:
> I have an add_custom_command in a subdirectory, and I'm trying to use
> that output as a dependency in a parent directory.
> 
> Unfortunately, the parent directory doesn't see that I made a rule
> (add_custom_command) for the file in the subdirectory.
> 
> 
> top level CMakeLists.txt:
> ...
> add_subdirectory(sub1)
> 
> add_custom_target(generate ALL
>   DEPENDS ${CMAKE_BINARY_DIR}/myfile.txt
>   )
> 
> sub1/CMakeLists.txt:
> add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/myfile.txt
>   COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/genmyfile.cmake
>   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
>   )

I would just do the add_custom_target in the same CMakeLists where you
do the add_custom_command. That target will still be available from your
top-level CMakeLists. I use this approach all over the place.

tyler
_______________________________________________
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