RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
991 stars 175 forks source link

:rocket: Use prebuild dependencies by default #3091

Open AnotherFoxGuy opened 9 months ago

AnotherFoxGuy commented 9 months ago

This removes the requirement for installing conan to build RoR Now cmake will download a prebuild dependencies tarball, extract it and run a small test to see if it is able to build with the dependencies Limitations of this system:

To build on Linux: Create a build dir: mkdir build && cd build Generate ninja files: cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. Build the game: ninja

To build on Windows: Create a build dir: mkdir build && cd build Generate VS studio files: cmake -G"Visual Studio 16 2019" .. Open the Rigs_of_Rods.sln file and switch the config to Release Build the game as usual

ohlidalp commented 8 months ago

My test setup:

Attempt 1 - basic commands

rmdir /S /Q "%USERPROFILE%\builds\rigs-of-rods"

cmake^
 -S "%USERPROFILE%\source\rigs-of-rods"^
 -B "%USERPROFILE%\builds\rigs-of-rods"^
 -G "Ninja"

ninja "%USERPROFILE%\builds\rigs-of-rods"

Result : Cmake said: No CMAKE_C_COMPILER could be found. No CMAKE_CXX_COMPILER could be found.

Attempt 2 - added compiler paths (Host64/x64)

 -D "CMAKE_C_COMPILER=c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe"^
 -D "CMAKE_CXX_COMPILER=c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe"^

Result

-- The C compiler identification is MSVC 19.37.32825.0
-- The CXX compiler identification is MSVC 19.37.32825.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

Attempt 3 (forced x64 build)

 -G "Ninja"^
 -A "x64"

OK this doesn't work:

CMake Error at CMakeLists.txt:19 (project):
  Generator

    Ninja

  does not support platform specification, but platform

    x64

  was specified.

Attempt4 (use x86 cl.exe)

 -D "CMAKE_C_COMPILER=c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x86/cl.exe"^
 -D "CMAKE_CXX_COMPILER=c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x86/cl.exe"^

Result

-- The C compiler identification is MSVC 19.37.32825.0
-- The CXX compiler identification is MSVC 19.37.32825.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x86/cl.exe
-- Check for working C compiler: c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x86/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "c:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x86/cl.exe"

  is not able to compile a simple test program.
AnotherFoxGuy commented 8 months ago

@ohlidalp On windows you have to run cmake and ninja in the Developer Command Prompt for VS 2019, otherwise cmake is unable to find the compiler and linker

ohlidalp commented 8 months ago

Sorry about the close/reopen, UI focused the Close button while I was typing for some reason.

OK, I'll keep that in mind for next time.

ohlidalp commented 8 months ago

I launched the same .cmd script from the Developer Command Prompt, without the paths to compiler. It chose "Hostx86/x86/cl.exe". But then failed without much detail:

-- Performing Test DEPS_CHECK
-- Performing Test DEPS_CHECK - Failed
CMake Error at cmake/DownloadDeps.cmake:46 (message):
  Failed to build test program with prebuild deps, please use conan
Call Stack (most recent call first):
  cmake/DownloadDeps.cmake:50 (run_deps_test)
  CMakeLists.txt:38 (include)
AnotherFoxGuy commented 6 months ago

@ohlidalp I updated the PR description with some better instructions on how to build on Windows

ohlidalp commented 2 weeks ago

Trying again. Same spec as above. Cmake latest. Conan uninstalled just to be sure.

rmdir /S /Q "%USERPROFILE%\builds\rigs-of-rods-prebuiltdeps"

cmake^
 -S "%USERPROFILE%\source\rigs-of-rods"^
 -B "%USERPROFILE%\builds\rigs-of-rods-prebuiltdeps"^
 -G "Visual Studio 17 2022"

pause

In visual studio, I select "Release" and do "Build Solution". Ends with:

12>LINK : fatal error C1047: The object or library file '..\..\_deps\dependencies-src\full_deploy\host\ogre3d-pagedgeometry\1.2.0\Release\x86_64\lib\PagedGeometry.lib' was created by a different version of the compiler than other objects like 'RoR.dir\Release\cmake_pch.obj'; rebuild all objects and libraries with the same compiler
12>LINK : fatal error LNK1257: code generation failed

Full logs attached

github 3091 - prebuilt.zip