(01-12-2014, 10:27 PM)worktycho Wrote: One option have just discovered is to have cmake run tolua++ during configure time using execute_process().
I'm trying that right now, but am having trouble - the command is not executed.
I currently have this code in the "MSVC" branch of $/src/CMakeLists.txt:
Code:
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/Bindings/Bindings.cpp")
message("Bindings.cpp not found, generating now")
execute_process(
COMMAND ${PROJECT_SOURCE_DIR}/src/Bindings/tolua++.exe -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
COMMAND echo test
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/Bindings
OUTPUT_VARIABLE ToLuaOut
ERROR_VARIABLE ToLuaErr
RESULT_VARIABLE TOLuaRes
)
message("Result:" ${ToLuaRes})
message("Output:" ${ToLuaOut})
message("Error: " ${ToLuaErr})
endif()
Code:
Bindings.cpp not found, generating now
Result:
Output:
Error:
Waitaminute! When I remove the tolua++ command and leave only the echo command, it works as expected.
Ah! It works! Seems like cmake cannot concat variables for the command, so I had to put the entire tolue++.exe path into a separate variable. This seems to have done the trick:
Code:
# Check the Bindings existence:
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/Bindings/Bindings.cpp")
message("Bindings.cpp not found, generating now")
set(tolua_executable ${PROJECT_SOURCE_DIR}/Bindings/tolua++.exe)
execute_process(
COMMAND ${tolua_executable} -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Bindings
OUTPUT_VARIABLE ToLuaOut
ERROR_VARIABLE ToLuaErr
RESULT_VARIABLE ToLuaRes
)
endif()