[CMake] Outputs from add_custom_command not global?

James Bigler jamesbigler at gmail.com
Sat Mar 28 02:16:21 EDT 2009


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.

Is there any way to make this work?

I've attached a simple build system to test this, but included the
salient parts below.

Thanks,
James

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}
  )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: subdir_generated.tar.gz
Type: application/x-gzip
Size: 586 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090328/3ac799c4/attachment-0001.bin>


More information about the CMake mailing list