[CMake] add_custom_command not creating rules when output file is not a c++ header/source file
Wojciech Mamrak
wmamrak at gmail.com
Sat Jun 21 15:36:12 EDT 2014
Hello List,
According to the docs:
A target created in the same directory that specifies any output of
the custom command as a source file is given a rule to generate the
file using the command at build time.
Above statement is clear and works fine if output file is .h/.cpp
file. And how about e.g. .txt files:
add_custom_command(OUTPUT foo.txt COMMAND create foo.txt)
add_executable(Foo foo.cpp foo.txt)
?
It turns out for me (visual studio 13) that CMake Rule is created if
foo.txt file does not exist. If it exists though, no rule is created.
Please forget for a while that this can be solved by using second
overload of add_custom_command, that usually cmake should be called
just once and on a clear directory (out of source building), or that
this file can be removed using file command.
best regards
More information about the CMake
mailing list