Transition to cmake on Windows
#1
I'd like to move to CMake on Windows, too. I'm exploring the options of the easiest transition options. I think I might cook up a quick script that would call cmake with the appropriate generator and create the bindings files.

In the meantime, can someone with Windows try the CMake approach manually, to verify that it works for them, too? STR? Tigerw? The basic instructions are: Clone a fresh new repo to a new folder, download and install cmake, make sure it's available system-wide by setting it in the PATH variable, then run "cmake ." in the repo root. CMake should build a solution file at the repo root, open that with VS and try compiling.
Reply
Thanks given by:
#2
I'm cloning now.

CMake is building.

VS 2008 is compiling.

Bindings didn't generate. I'l have to do that myself first.

Error:
Code:
1>------ Build started: Project: MCServer, Configuration: Debug Win32 ------
1>Compiling...
1>LuaState.cpp
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Linking...
1>   Creating library G:\MCServer\CMake\MCServer\MCServer\Debug\..\MCServer_debug.lib and object G:\MCServer\CMake\MCServer\MCServer\Debug\..\MCServer_debug.exp
1>LuaState.obj : error LNK2019: unresolved external symbol "int __cdecl tolua_AllToLua_open(struct lua_State *)" (?tolua_AllToLua_open@@YAHPAUlua_State@@@Z) referenced in function "public: void __thiscall cLuaState::Create(void)" (?Create@cLuaState@@QAEXXZ)
1>G:\MCServer\CMake\MCServer\MCServer\Debug\..\MCServer_debug.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://g:\MCServer\CMake\MCServer\src\MCServer.dir\Debug\BuildLog.htm"
1>MCServer - 2 error(s), 0 warning(s)
2>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32 ------
2>Project not selected to build for this solution configuration
========== Build: 0 succeeded, 1 failed, 12 up-to-date, 1 skipped ==========

Buildlog:
.htm   BuildLog.htm (Size: 26.64 KB / Downloads: 358)
Reply
Thanks given by: xoft
#3
Hm, the windows version of the CMake script requires that Bindings are generated before running CMake. I'll try to fix that.
Reply
Thanks given by: NiLSPACE
#4
I reported this too with your windows cmake PRTongue
Reply
Thanks given by:
#5
Also it seems it doesn't compile Lua (or it doesn't compile it as an dll).
Reply
Thanks given by:
#6
Yes, but that was older code. I was hoping to have fixed this.
Apparently it is impossible to do right now, so we'll have to stick to the manual way - first generate bindings, then run CMake.

STR, can you delete your $/CMakeCache.txt file, run $/src/Bindings/AllToLua.bat and then try CMake again?
Reply
Thanks given by:
#7
Yes it compiles fine when I do that.

But I can't start the server because lua.dll is missing.

the lua.dll is compiled in $lib/lua/<MODE>

Should be fixed when you add
Quote:set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/MCServer")
in the lua CMakeList.txt in the if (WIN32).
Reply
Thanks given by:
#8
(01-12-2014, 09:32 PM)xoft Wrote: Yes, but that was older code. I was hoping to have fixed this.
Apparently it is impossible to do right now, so we'll have to stick to the manual way - first generate bindings, then run CMake.

STR, can you delete your $/CMakeCache.txt file, run $/src/Bindings/AllToLua.bat and then try CMake again?

One option have just discovered is to have cmake run tolua++ during configure time using execute_process(). You would then need to rerun cmake every time you changed the bindings but its a little simpler for those not working on bindings.
Reply
Thanks given by:
#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:
#10
Okay, how about now, can you retry?
And Tigerw, can you try with your faaavorite VS2013? Smile
Reply
Thanks given by:




Users browsing this thread: 4 Guest(s)