[CMake] Question about dependencies for install (FILES...)

Alexander Neundorf a.neundorf-work at gmx.net
Sat Jan 16 14:17:58 EST 2010


On Saturday 16 January 2010, Christoph Cullmann wrote:
> Hi,
>
> I try to install a flex generated file: (lex.loopmap_.cpp)
>
> CMakeLists.txt excerpt:
>
> set (cfg_cfiles_install
>         files
>         conmap.cpp
>         loopmap.cpp
>         regmap.cpp
>         mapping.cpp
>         lex.loopmap_.cpp
>         paggdl.cpp
>         scc.cpp
>         sort.cpp
>         sort_exp.cpp
> )
>
> # install some source files
> install(FILES ${cfg_cfiles_install} DESTINATION ${CFGDIR_C})
>
> # targets to refresh the scanner
> ADD_CUSTOM_COMMAND(
>     OUTPUT "lex.loopmap_.cpp"
>     COMMAND flex ARGS -8 -Ploopmap_ -olex.loopmap_.cpp map.lex
>     DEPENDS "map.lex"
>     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
>
>
> But CMake doesn't call flex and fails at install.

Because there is no target which needs the generated files.
You could use add_custom_target(... ALL ...) instead of add_custom_command(), 
then it will always be built.

Alex


> How do I tell it the dependency to generate the file on demand if not there
> or the .lex was changed?



More information about the CMake mailing list