[CMake] How to correctly set dependencies for header files generated in another directory
Alexander Usov
a.s.usov at gmail.com
Fri Mar 9 11:42:08 EST 2012
Hi,
I'm trying to figure out how to correctly set up dependencies for
generated header files.
I have prepared an example setup here: http://github.com/usovalx/cmake_test.git
Quick summary:
root/CMakeLists.txt:
add_subdirectory(sub1)
add_subdirectory(sub2)
sub2/CMakeLists.txt:
add_custom_command(
OUTPUT tt.h tt.c
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gen.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM)
add_custom_target(sub2Hxx)
add_dependencies(sub2Hxx tt.h tt.c)
add_library(t2 gen.sh tt.c tt.h)
add_dependencies(t2 sub2Hxx)
sub1/CMakeLists.txt:
add_executable(t1 main.c)
add_dependencies(t1 sub2Hxx)
sub1/main.c:
#include "../sub2/tt.h"
Now if I'm trying to build target t1 compilation fails because
generator script didn't run.
What is the correct way to trigger code generation in this case?
--
Best regards,
Alexander.
More information about the CMake
mailing list