[CMake] Question about generate a source file during the build

Olaf Peter ope-devel at gmx.de
Sun Feb 3 14:12:41 EST 2013


Hi Sébastien,

 >  > ---8<---
 >  > project(coolcoding)
 >  >
 >  > # generate coolcoding's static lexer
 >  > set(COOLCODING_BAR_HPP
 > ${PROJECT_BINARY_DIR}/include/foo/io/coolcoding/coolcoding_bar.hpp)
 >  >
 >  > add_executable(generate_coolcoding_bar generate_coolcoding_bar.cpp)
 >  >
 >  > add_custom_command(
 >  >    OUTPUT  ${COOLCODING_BAR_HPP}
 >  >    COMMAND generate_coolcoding_bar ${COOLCODING_BAR_HPP}
 >  >    )
 >
 > You might want to add
 >
 > DEPENDS generate_coolcoding_bar
 >
 > to this command.
 >

IMO the DEPENDS is only useful if you have an input file dependency, 
which isn't here the case.

file(MAKE_DIRECTORY ${directory})

did help, but is verbose since I use set(DIR ...) and set(HPP 
${DIR}/...). It would be nice if cmake would know that there is a 
directory to create....

Thanks,
Olaf




More information about the CMake mailing list