03-31-2016, 05:06 PM
(This post was last modified: 08-10-2018, 08:24 PM by Simbax.
Edit Reason: Mybb removing images for no reason
)
New Way
With a nice C++ package manager from Microsoft and VS >=2015 support for CMake projects, the prebuilt packages are no longer needed.
Installing tools and dependencies
Note that we're doing static building in order to avoid problems with DLLs. If you want to do a dynamic build, use triplet without -static suffix and remove the -D?_STATIC variables from CMakeSettings.json. Be prepared for having issues with that though. Some DLLs are copied automatically and some are not.
Do the following:
Follow the instructions to install vcpkg and in the root of the directory where you downloaded it, run this command:
vcpkg.exe install boost sdl2 sdl2-ttf sdl2-image glew libpng libwebp tiff gettext libsndfile libvorbis libogg openal-soft physfs --triplet x86-windows-static
Note: For x64 support, change to --triplet x64-windows-static to the command above.
Clone or download the Colobot source code, preferably using git. You also need Colobot data source. Note: This way is currently supported only by dev branch. For any other branch, you must use the old way or wait until they merge with dev.
Unfortunately, the necessary command line tools need to be installed manually, unless there is another package manager with them that I'm not aware of. Download the following in form of ZIPs:
Compiling Colobot
You probably want to launch Colobot with some command line parameters. Use the menu CMake -> Debug and Launch Settings -> colobot.exe (install) and in the opened file add "args": ["-param1", "-param2", ..., "-paramN"] to the "configurations" object.
Old Way
With a nice C++ package manager from Microsoft and VS >=2015 support for CMake projects, the prebuilt packages are no longer needed.
Installing tools and dependencies
Note that we're doing static building in order to avoid problems with DLLs. If you want to do a dynamic build, use triplet without -static suffix and remove the -D?_STATIC variables from CMakeSettings.json. Be prepared for having issues with that though. Some DLLs are copied automatically and some are not.
Do the following:
- Install Visual Studio with at least the following workloads:
- Desktop development with C++ (it provides the CMake support among other things)
- Python development (unless you already have Python >=2.7 installed)
- Game development with C++ (not sure if it's needed actually, but better safe than sorry)
vcpkg.exe install boost sdl2 sdl2-ttf sdl2-image glew libpng libwebp tiff gettext libsndfile libvorbis libogg openal-soft physfs --triplet x86-windows-static
Note: For x64 support, change to --triplet x64-windows-static to the command above.
- gettext (take content of bin/) obligatory
- oggenc (rename oggenc2.exe to oggenc.exe) for converting music
- wget for downloading music, if you don't care just remember to add -DMUSIC=0 to CMake parameteres (in the next section)
- rsvg-convert for desktop icons
- xmlstarlet (rename xml.exe to xmlstarlet.exe) for desktop icons
Compiling Colobot
- Open Visual Studio.
- From the menu choose File -> Open -> CMake..., then select the CMakeLists.txt file in the root of the Colobot source code directory. At this point there will be errors in the output window, don't worry about that just yet.
- CMake -> Change CMake Settings -> CMakeLists.txt. A new file CMakeLists.json will open with at least 4 configurations (x86/x64-release/debug). Set:
- cmakeCommandArgs to "-DCMAKE_TOOLCHAIN_FILE={{PATH_TO_VCPKG}}/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x86-windows-static -DBOOST_STATIC=1 -DGLEW_STATIC=1 -DMSVC_STATIC=1". You can add other parameters here too, like -DDEV_BUILD=1 or -DMUSIC=0.
- configurationType to "Release" if for some reason it is set to "RelWithDebInfo" or something else (it simply doesn't work, I don't know why).
- In the top toolbar, choose the correct configuration (x86/x64-debug/release). Use "release" if you want a clean build like the one you can download from the official webpage. For development I recommend "debug".
- CMake -> Cache -> Delete Cache Folders, then CMake -> Cache -> Generate. There should be no errors. If there are, then I'm afraid you're on your own. Make sure you've done everything so far correctly. Ask for help the community if you need.
- Next to the configuration option from step 4 there now should be a button with green arrow. Choose "colobot.exe (install)" (because we want to install the data files) and click the green arrow. You can also use Build -> Build Solution if you don't want to run the game after the build. You can probably use "colobot.exe" without "(install)" if you don't change the data files frequently.
- Enjoy the game!
You probably want to launch Colobot with some command line parameters. Use the menu CMake -> Debug and Launch Settings -> colobot.exe (install) and in the opened file add "args": ["-param1", "-param2", ..., "-paramN"] to the "configurations" object.
Old Way
Spoiler :