Proper way to call a found executable in a custom command?

Viewed 15030

I have a program on my computer, let's say C:/Tools/generate_v23_debug.exe

I have a FindGenerate.cmake file which allows CMake to find that exact path to the executable.

So in my CMake code, I do:

find_program(Generate)
if (NOT Generate_FOUND)
    message(FATAL_ERROR "Generator not found!")

So CMake has found the executable. Now I want to call this program in a custom command statement. Should I use COMMAND Generator or COMMAND ${GENERATOR_EXECUTABLE}? Will both of these do the same thing? Is one preferred over the other? Is name_EXECUTABLE a variable that CMake will define (it's not in the FindGenerate.cmake file), or is it something specific to someone else's example code I'm looking at? Will COMMAND Generator be expanded to the correct path?

add_custom_command(
    OUTPUT blahblah.txt
    COMMAND Generator inputfile1.log
    DEPENDS Generator
)
1 Answers
Related