From b36767904acd3526be4bad5732162f6ae7225d6b Mon Sep 17 00:00:00 2001 From: Alexander Wilms Date: Sun, 8 Oct 2023 21:18:44 +0200 Subject: [PATCH 1/2] Mention ccache in developer docs --- docs/developers/Building_Linux.md | 11 ++++++++--- docs/developers/Building_Windows.md | 9 ++++++++- docs/developers/Building_macOS.md | 4 +++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/developers/Building_Linux.md b/docs/developers/Building_Linux.md index 0add5e91e..811f480d8 100644 --- a/docs/developers/Building_Linux.md +++ b/docs/developers/Building_Linux.md @@ -19,13 +19,15 @@ To compile, the following packages (and their development counterparts) are need - Boost C++ libraries v1.48+: program-options, filesystem, system, thread, locale - Recommended, if you want to build launcher or map editor: Qt 5, widget and network modules - Recommended, FFmpeg libraries, if you want to watch in-game videos: libavformat and libswscale. Their name could be libavformat-devel and libswscale-devel, or ffmpeg-libs-devel or similar names. -- Optional, if you want to build scripting modules: LuaJIT +- Optional: + - if you want to build scripting modules: LuaJIT + - to speed up recompilation: Ccache ## On Debian-based systems (e.g. Ubuntu) For Ubuntu and Debian you need to install this list of packages: -`sudo apt-get install cmake g++ clang libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev zlib1g-dev libavformat-dev libswscale-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-locale-dev qtbase5-dev libtbb-dev libluajit-5.1-dev qttools5-dev ninja-build` +`sudo apt-get install cmake g++ clang libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev zlib1g-dev libavformat-dev libswscale-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-locale-dev qtbase5-dev libtbb-dev libluajit-5.1-dev qttools5-dev ninja-build ccache` Alternatively if you have VCMI installed from repository or PPA you can use: @@ -33,7 +35,7 @@ Alternatively if you have VCMI installed from repository or PPA you can use: ## On RPM-based distributions (e.g. Fedora) -`sudo yum install cmake gcc-c++ SDL2-devel SDL2_image-devel SDL2_ttf-devel SDL2_mixer-devel boost boost-devel boost-filesystem boost-system boost-thread boost-program-options boost-locale zlib-devel ffmpeg-devel ffmpeg-libs qt5-qtbase-devel tbb-devel luajit-devel fuzzylite-devel` +`sudo yum install cmake gcc-c++ SDL2-devel SDL2_image-devel SDL2_ttf-devel SDL2_mixer-devel boost boost-devel boost-filesystem boost-system boost-thread boost-program-options boost-locale zlib-devel ffmpeg-devel ffmpeg-libs qt5-qtbase-devel tbb-devel luajit-devel fuzzylite-devel ccache` NOTE: `fuzzylite-devel` package is no longer available in recent version of Fedora, for example Fedora 38. It's not a blocker because VCMI bundles fuzzylite lib in its source code. @@ -73,6 +75,9 @@ cmake ../vcmi **Notice**: The ../vcmi/ is not a typo, it will place makefile scripts into the build dir as the build dir is your working dir when calling CMake. +## To use ccache: +`cmake ../vcmi -DCMAKE_COMPILER_LAUNCHER=ccache` + ## Trigger build `cmake --build . -- -j2` diff --git a/docs/developers/Building_Windows.md b/docs/developers/Building_Windows.md index cab0722dc..e9e758581 100644 --- a/docs/developers/Building_Windows.md +++ b/docs/developers/Building_Windows.md @@ -10,7 +10,10 @@ Windows builds can be made in more than one way and with more than one tool. Thi - Git or git GUI, for example, SourceTree [download link](http://www.sourcetreeapp.com/download) - CMake [download link](https://cmake.org/download/). During install after accepting license agreement make sure to check "Add CMake to the system PATH for all users". - To unpack pre-build Vcpkg: [7-zip](http://www.7-zip.org/download.html) -- Optionally, to create installer: [NSIS](http://nsis.sourceforge.net/Main_Page) +- To speed up recompilation: [CCache](https://github.com/ccache/ccache/releases) +- Optional: + - To create installer: [NSIS](http://nsis.sourceforge.net/Main_Page) + ## Choose an installation directory @@ -75,6 +78,10 @@ From command line use: For the list of the packages used you can also consult [vcmi-deps-windows readme](https://github.com/vcmi/vcmi-deps-windows) in case this article gets outdated a bit. +### CCache + +Extract `ccache` to a folder of your choosing, add the folder to the `PATH` environment variable and log out and back in. + # Build VCMI #### From GIT GUI diff --git a/docs/developers/Building_macOS.md b/docs/developers/Building_macOS.md index d6557e5f2..558e5338f 100644 --- a/docs/developers/Building_macOS.md +++ b/docs/developers/Building_macOS.md @@ -7,7 +7,9 @@ - Xcode IDE: - (not tested) other C++ compilers, e.g. gcc/clang from [Homebrew](https://brew.sh/) 2. CMake: `brew install --cask cmake` or get from -3. (optional) Ninja: `brew install ninja` or get from +3. CCache to speed up recompilation: `brew install ccache` +4. Optional: + * Ninja: `brew install ninja` or get it from # Obtaining source code From 9bbd2a58bca4d33510cba9e20fee13c30a3d4ecc Mon Sep 17 00:00:00 2001 From: Alexander Wilms Date: Sun, 8 Oct 2023 21:47:09 +0200 Subject: [PATCH 2/2] Improve docs --- docs/developers/Building_Android.md | 6 ++++-- docs/developers/Building_Linux.md | 4 ++-- docs/developers/Building_Windows.md | 11 +++++++---- docs/developers/Building_iOS.md | 6 +++++- docs/developers/Building_macOS.md | 5 +++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/docs/developers/Building_Android.md b/docs/developers/Building_Android.md index 6800dc7e2..6f04b71a5 100644 --- a/docs/developers/Building_Android.md +++ b/docs/developers/Building_Android.md @@ -14,7 +14,9 @@ The following instructions apply to **v1.2 and later**. For earlier versions the - install with `sdkmanager` command line tool - download from https://developer.android.com/ndk/downloads - download with Conan, see [#NDK and Conan](#ndk-and-conan) -5. (optional) Ninja: download from your package manager or from https://github.com/ninja-build/ninja/releases +5. Optional: + - Ninja: download from your package manager or from https://github.com/ninja-build/ninja/releases + - Ccache: download from your package manager or from https://github.com/ccache/ccache/releases ## Obtaining source code @@ -60,7 +62,7 @@ Building for Android is a 2-step process. First, native C++ code is compiled to This is a traditional CMake project, you can build it from command line or some IDE. You're not required to pass any custom options (except Conan toolchain file), defaults are already good. If you wish to use your own CMake presets, inherit them from our `build-with-conan` preset. Example: ``` -cmake -S . -B ../build -G Ninja -D CMAKE_BUILD_TYPE=Debug --toolchain ... +cmake -S . -B ../build -G Ninja -D CMAKE_BUILD_TYPE=Debug -D CMAKE_COMPILER_LAUNCHER=ccache --toolchain ... cmake --build ../build ``` diff --git a/docs/developers/Building_Linux.md b/docs/developers/Building_Linux.md index 811f480d8..a1371532c 100644 --- a/docs/developers/Building_Linux.md +++ b/docs/developers/Building_Linux.md @@ -71,12 +71,12 @@ cmake ../vcmi # Additional options that you may want to use: ## To enable debugging: -`cmake ../vcmi -DCMAKE_BUILD_TYPE=Debug` +`cmake ../vcmi -D CMAKE_BUILD_TYPE=Debug` **Notice**: The ../vcmi/ is not a typo, it will place makefile scripts into the build dir as the build dir is your working dir when calling CMake. ## To use ccache: -`cmake ../vcmi -DCMAKE_COMPILER_LAUNCHER=ccache` +`cmake ../vcmi -D CMAKE_COMPILER_LAUNCHER=ccache` ## Trigger build diff --git a/docs/developers/Building_Windows.md b/docs/developers/Building_Windows.md index e9e758581..1ba751662 100644 --- a/docs/developers/Building_Windows.md +++ b/docs/developers/Building_Windows.md @@ -10,10 +10,9 @@ Windows builds can be made in more than one way and with more than one tool. Thi - Git or git GUI, for example, SourceTree [download link](http://www.sourcetreeapp.com/download) - CMake [download link](https://cmake.org/download/). During install after accepting license agreement make sure to check "Add CMake to the system PATH for all users". - To unpack pre-build Vcpkg: [7-zip](http://www.7-zip.org/download.html) -- To speed up recompilation: [CCache](https://github.com/ccache/ccache/releases) - Optional: - To create installer: [NSIS](http://nsis.sourceforge.net/Main_Page) - + - To speed up recompilation: [CCache](https://github.com/ccache/ccache/releases) ## Choose an installation directory @@ -78,7 +77,7 @@ From command line use: For the list of the packages used you can also consult [vcmi-deps-windows readme](https://github.com/vcmi/vcmi-deps-windows) in case this article gets outdated a bit. -### CCache +# Install CCache Extract `ccache` to a folder of your choosing, add the folder to the `PATH` environment variable and log out and back in. @@ -104,7 +103,11 @@ Extract `ccache` to a folder of your choosing, add the folder to the `PATH` envi ## Compile VCMI with Visual Studio - Open `%VCMI_DIR%/build/VCMI.sln` in Visual Studio -- Select `Release` build type in combobox +- Select `Release` build type in the combobox +- If you want to use ccache: + - Select `Manage Configurations...` in the combobox + - Specify the following CMake variable: `ENABLE_CCACHE=ON` + - See the [Visual Studio documentation](https://learn.microsoft.com/en-us/cpp/build/customize-cmake-settings?view=msvc-170#cmake-variables-and-cache) for details - Right click on `BUILD_ALL` project. This `BUILD_ALL` project should be in `CMakePredefinedTargets` tree in Solution Explorer. - VCMI will be built in `%VCMI_DIR%/build/bin` folder! diff --git a/docs/developers/Building_iOS.md b/docs/developers/Building_iOS.md index 22a67d85a..e16bc1ff6 100644 --- a/docs/developers/Building_iOS.md +++ b/docs/developers/Building_iOS.md @@ -5,6 +5,8 @@ 1. **macOS** 2. Xcode: 3. CMake 3.21+: `brew install --cask cmake` or get from +4. Optional: + - CCache to speed up recompilation: `brew install ccache` ## Obtaining source code @@ -39,7 +41,9 @@ cmake --preset ios-device-conan \ -D BUNDLE_IDENTIFIER_PREFIX=com.MY-NAME ``` -By default build directory containing Xcode project will appear at `../build-ios-device-conan`, but you can change it with `-B` option. +By default build directory containing Xcode project will appear at `../build-ios-device-conan`, but you can change it with `-B` option. + +If you want to speed up the recompilation, add `-D ENABLE_CCACHE=ON` ### Building for device diff --git a/docs/developers/Building_macOS.md b/docs/developers/Building_macOS.md index 558e5338f..9052d2915 100644 --- a/docs/developers/Building_macOS.md +++ b/docs/developers/Building_macOS.md @@ -7,9 +7,9 @@ - Xcode IDE: - (not tested) other C++ compilers, e.g. gcc/clang from [Homebrew](https://brew.sh/) 2. CMake: `brew install --cask cmake` or get from -3. CCache to speed up recompilation: `brew install ccache` 4. Optional: * Ninja: `brew install ninja` or get it from + * CCache to speed up recompilation: `brew install ccache` # Obtaining source code @@ -71,7 +71,8 @@ Note that if you wish to use Qt Creator IDE, you should skip this step and confi - if you installed Qt 5 from Homebrew, insert:`$(brew --prefix qt@5)` - if you installed Qt from Online Installer, insert your path to Qt directory, for example: `/Users/kambala/dev/Qt-libs/5.15.2/Clang64` - example for FFmpeg + Qt 5: `-D "CMAKE_PREFIX_PATH=$(brew --prefix ffmpeg@4);$(brew --prefix qt@5)"` -8. now press Return +8. If you want to speed up the recompilation, add `-D ENABLE_CCACHE=ON` +9. Now press Return # Building project