u3d-community / U3D

Open-source, cross-platform 2D and 3D game engine built in C++
https://u3d.io
MIT License
160 stars 26 forks source link

Fix Issues Building For Web on Windows #65

Open BlueMagnificent opened 4 months ago

BlueMagnificent commented 4 months ago

Two issues are currently encountered when building Urho3D for Web on Windows.

  1. While setting up a build by directly or indirectly calling script\cmake_generic.bat, an infinite loop will occur when the -D options is not followed by a space, see #59. Example script\cmake_vs2022.bat build -DURHO3D_SAMPLES=1. This can easily be avoided by adding the needed space after -D. However when used with Emscripten's emcmake to setup for Web, the infinite loop will be encountered once more because emcmake emits the CMAKE_TOOLCHAIN_FILE and CMAKE_CROSSCOMPILING_EMULATOR build options with no space after -D.

    Additionally, emcmake emits the MinGW makefiles generator flag without quotes around MinGW Makefiles and this breaks CMake.

  2. In Source\Tools\CMakeLists.txt, the CMake command to install PackageTool and BindingGenerator under the CMAKE_CROSSCOMPILING option specifies these files without an extension. When building for Web on Windows, the builds are successful but installation fails with error file INSTALL cannot find <path/to/file> because the file being looked for has no extension while the actual file that was built has .exe extension.

This PR fixes the above mentioned issues and was tested on a Windows 11 machine using Emscripten version 3.1.59 ( the latest version at the time of this post)