Bill Hoffman escreveu:
OK, I know I will regret this, but how would lua help here? Other than the myscript.cmake would be myscript.lua and the syntax would by slightly different, it would be the exact same thing. The issue is that cmake and whatever language it uses is not around at build time unless you call it. cmake creates makefiles/projects and it is no longer running. Now one solution to this would be to add a feature to the add_custom_command that ignores the result of the command you are running. Your example is a bit odd as well...

Heheh, no worries, I don't intend to begin that old argument about using lua (although it's in my list of things that would make my life easier, along with boost using cmake (and not bjam)). In my dream world, using lua I might write:

function call_command()
{
        -- I think that passing 'COMMAND' is not needed, but it's ok if
        -- one cares about maintaining the cmake script syntax.
        ret = execute_process(COMMAND, "whatever");
        -- do something with ret
        return true; -- or false, to make the build stop
}

add_custom_command(OUTPUT, "text.cpp" COMMAND call_command);

Although you have a point by saying that cmake should not run during the build, the above construction allows it to generate the correct projects without needing cmake during build. The function add_custom_command would call 'call_command' during project creation (not build time) and setup the process call and its return value processing.

add_custom_command(OUTPUT text.cpp COMMAND false)
add_executable(test main.cpp text.cpp)

In this case text.cpp would not be created and the build would fail when text.cpp was compiled...

Ok, it's not the best example possible, but suppose that the command returned something different than 0, even if it created the output file?

Regards,
rod

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to