[CMake] Dependencies of generated files
Olaf Peter
ope-devel at gmx.de
Wed Feb 13 13:20:11 EST 2013
Hello,
obviously I have a problem with the understanding of generating
dependencies of generated files.
generate_foo_static_lexer is using ${foo_LEXER_HPP} to generate a header
file ${foo_STATIC_LEXER_HPP}. Each time ${foo_STATIC_LEXER_HPP} is
changed the header shall be regenerated. Later, ${foo_STATIC_LEXER_HPP}
can be more than one file (maybe list(xxx_HPP A;B;C)?? ).
But this doesn't happen, only the exe is re-created. What's wrong?
project(foo)
# generate foo's static lexer into the root of out-of-source build directory
set(foo_INCLUDE_PATH ${CMAKE_BINARY_DIR}/include/foo/io/foo)
set(foo_STATIC_LEXER_HPP ${foo_INCLUDE_PATH}/foo_static_lexer.hpp)
file(MAKE_DIRECTORY ${foo_INCLUDE_PATH})
set(foo_LEXER_HPP ${CMAKE_SOURCE_DIR}/include/foo/io/foo/lexer_impl.hpp)
add_executable(generate_foo_static_lexer generate_foo_static_lexer.cpp)
set_target_properties(generate_foo_static_lexer PROPERTIES
COMPILE_DEFINITIONS "foo_LEXER_DYNAMIC_TABLES;BOOST_SPIRIT_LEXERTL_DEBUG")
add_custom_command(
OUTPUT ${foo_STATIC_LEXER_HPP}
COMMAND generate_foo_static_lexer ${foo_STATIC_LEXER_HPP}
COMMENT "Generating foo static DFA lexer header ${foo_STATIC_LEXER_HPP}"
)
add_custom_target(foo_dfa DEPENDS ${foo_LEXER_HPP})
add_dependencies(foo_dfa generate_foo_static_lexer)
set_source_files_properties(${foo_STATIC_LEXER_HPP} PROPERTIES GENERATED 1)
More information about the CMake
mailing list