Reputation: 892
I need to somehow generate .fidl
files based on .cpp
and .hpp
files.
The problem is that if I try to use add_custom_target
it runs every time.
For add_custom_command
I need specify output files, but I do not want to do it.
I'd like to do something like this:
add_custom_command(gen_fidl
DEPENDS "*.fidl"
COMMAND <My Commands>)
But in this case I need specify a rule for .fidl
files
How would I be able to do something like this?
Upvotes: 3
Views: 2502
Reputation: 74
The general answer is following: If you don't know which files are generated, you should use approach with "fake" file like Denis Kotov suggested. Otherwise something like that is better:
# definition of fidl_list
add_custom_command( OUTPUT ${fidl_list}
DEPENDS ${input_files_or_folders_for_generation}
COMMAND <command_to_do> )
add_custom_target(fidl_gen DEPENDS ${fidl_list})
Upvotes: 1
Reputation: 892
I've found the following solution:
add_custom_command(
OUTPUT fidl_generated_successfully
DEPENDS ./cmake-build-debug/*.fidl
COMMAND touch fidl_generated_successfully
COMMAND <COMMAND TO DO>)
add_custom_target(
fidl_gen
DEPENDS fidl_generated_successfully)
add_dependencies(${PROJECT_NAME} fidl_gen)
But the issue there is the generation on the file (fidl_generated_successfully). Are there anywhere better solution without creating useless file fidl_generated_successfully
Upvotes: 2