Transition to cmake on Windows
#9
(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()
I get the following output, which I interpret as "no command has been run":
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()
Reply
Thanks given by:


Messages In This Thread
Transition to cmake on Windows - by xoft - 01-12-2014, 08:32 PM
RE: Transition to cmake on Windows - by NiLSPACE - 01-12-2014, 08:36 PM
RE: Transition to cmake on Windows - by xoft - 01-12-2014, 09:18 PM
RE: Transition to cmake on Windows - by tigerw - 01-12-2014, 09:19 PM
RE: Transition to cmake on Windows - by NiLSPACE - 01-12-2014, 09:31 PM
RE: Transition to cmake on Windows - by xoft - 01-12-2014, 09:32 PM
RE: Transition to cmake on Windows - by worktycho - 01-12-2014, 10:27 PM
RE: Transition to cmake on Windows - by xoft - 01-12-2014, 11:26 PM
RE: Transition to cmake on Windows - by NiLSPACE - 01-12-2014, 09:34 PM
RE: Transition to cmake on Windows - by xoft - 01-14-2014, 02:16 AM
RE: Transition to cmake on Windows - by xoft - 01-14-2014, 06:33 AM
RE: Transition to cmake on Windows - by bearbin - 01-14-2014, 06:40 AM
RE: Transition to cmake on Windows - by NiLSPACE - 01-14-2014, 06:45 AM
RE: Transition to cmake on Windows - by ThuGie - 01-14-2014, 07:30 AM
RE: Transition to cmake on Windows - by xoft - 01-14-2014, 04:34 PM
RE: Transition to cmake on Windows - by tigerw - 01-14-2014, 09:02 AM
RE: Transition to cmake on Windows - by xoft - 01-14-2014, 06:41 PM
RE: Transition to cmake on Windows - by xoft - 01-15-2014, 11:46 PM
RE: Transition to cmake on Windows - by NiLSPACE - 01-16-2014, 12:01 AM
RE: Transition to cmake on Windows - by xoft - 01-16-2014, 12:47 AM
RE: Transition to cmake on Windows - by tigerw - 01-16-2014, 04:42 AM
RE: Transition to cmake on Windows - by xoft - 01-16-2014, 06:29 AM
RE: Transition to cmake on Windows - by tigerw - 01-16-2014, 09:28 AM
RE: Transition to cmake on Windows - by xoft - 01-16-2014, 06:56 PM
RE: Transition to cmake on Windows - by xoft - 01-16-2014, 09:41 PM
RE: Transition to cmake on Windows - by tigerw - 01-17-2014, 04:17 AM
RE: Transition to cmake on Windows - by xoft - 01-17-2014, 05:18 AM
RE: Transition to cmake on Windows - by tigerw - 01-17-2014, 05:47 AM
RE: Transition to cmake on Windows - by bearbin - 01-17-2014, 06:02 AM
RE: Transition to cmake on Windows - by xoft - 01-17-2014, 06:42 AM
RE: Transition to cmake on Windows - by tigerw - 01-17-2014, 07:20 AM
RE: Transition to cmake on Windows - by xoft - 01-17-2014, 05:11 PM
RE: Transition to cmake on Windows - by tigerw - 01-18-2014, 05:17 AM
RE: Transition to cmake on Windows - by xoft - 01-18-2014, 09:28 AM
RE: Transition to cmake on Windows - by ThuGie - 01-19-2014, 10:30 AM
RE: Transition to cmake on Windows - by xoft - 01-19-2014, 05:02 PM
RE: Transition to cmake on Windows - by ThuGie - 01-19-2014, 11:06 PM
RE: Transition to cmake on Windows - by xoft - 01-19-2014, 11:48 PM
RE: Transition to cmake on Windows - by tigerw - 01-20-2014, 12:42 AM
RE: Transition to cmake on Windows - by xoft - 01-20-2014, 01:21 AM
RE: Transition to cmake on Windows - by ThuGie - 01-20-2014, 03:10 AM



Users browsing this thread: 1 Guest(s)