1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Merge pull request #3421 from Kuxe/windows_mingw_cmake_preset

Add 'windows-mingw-release' CMake preset
This commit is contained in:
Ivan Savenko 2024-01-05 00:09:28 +02:00 committed by GitHub
commit 396c6658df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 8 deletions

View File

@ -94,9 +94,8 @@ if(ENABLE_CCACHE)
find_program(CCACHE ccache REQUIRED) find_program(CCACHE ccache REQUIRED)
endif() endif()
# On Linux, use ccache via CMAKE_CXX_COMPILER_LAUNCHER.
# The XCode and MSVC builds each require some more configuration further down. # The XCode and MSVC builds each require some more configuration further down.
if(ENABLE_CCACHE AND LINUX) if(ENABLE_CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER "ccache") set(CMAKE_C_COMPILER_LAUNCHER "ccache")
set(CMAKE_CXX_COMPILER_LAUNCHER "ccache") set(CMAKE_CXX_COMPILER_LAUNCHER "ccache")
endif() endif()

View File

@ -127,6 +127,15 @@
"CMAKE_CXX_COMPILER": "/usr/bin/g++" "CMAKE_CXX_COMPILER": "/usr/bin/g++"
} }
}, },
{
"name": "windows-mingw-release",
"displayName": "Windows x64 MinGW Release",
"description": "VCMI Windows Ninja using MinGW",
"inherits": "default-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{ {
"name": "windows-msvc-release", "name": "windows-msvc-release",
"displayName": "Windows x64 RelWithDebInfo", "displayName": "Windows x64 RelWithDebInfo",
@ -352,6 +361,11 @@
"configurePreset": "macos-arm-conan-ninja-release", "configurePreset": "macos-arm-conan-ninja-release",
"inherits": "default-release" "inherits": "default-release"
}, },
{
"name": "windows-mingw-release",
"configurePreset": "windows-mingw-release",
"inherits": "default-release"
},
{ {
"name": "windows-msvc-release", "name": "windows-msvc-release",
"configurePreset": "windows-msvc-release", "configurePreset": "windows-msvc-release",
@ -438,6 +452,11 @@
"configurePreset": "macos-ninja-release", "configurePreset": "macos-ninja-release",
"inherits": "default-release" "inherits": "default-release"
}, },
{
"name": "windows-mingw-release",
"configurePreset": "windows-mingw-release",
"inherits": "default-release"
},
{ {
"name": "windows-msvc-release", "name": "windows-msvc-release",
"configurePreset": "windows-msvc-release", "configurePreset": "windows-msvc-release",

View File

@ -29,11 +29,11 @@ std::optional<ColorRGBA> Colors::parseColor(std::string text)
{ {
std::smatch match; std::smatch match;
std::regex expr("^#([0-9a-fA-F]{6})$"); std::regex expr("^#([0-9a-fA-F]{6})$");
ui8 rgb[3] = {0, 0, 0}; std::vector<ui8> rgb;
rgb.reserve(3);
if(std::regex_search(text, match, expr)) if(std::regex_search(text, match, expr))
{ {
std::string tmp = boost::algorithm::unhex(match[1].str()); boost::algorithm::unhex(match[1].str(), std::back_inserter(rgb));
std::copy(tmp.begin(), tmp.end(), rgb);
return ColorRGBA(rgb[0], rgb[1], rgb[2]); return ColorRGBA(rgb[0], rgb[1], rgb[2]);
} }
@ -42,8 +42,7 @@ std::optional<ColorRGBA> Colors::parseColor(std::string text)
for(auto & color : colors) { for(auto & color : colors) {
if(boost::algorithm::to_lower_copy(color.first) == boost::algorithm::to_lower_copy(text)) if(boost::algorithm::to_lower_copy(color.first) == boost::algorithm::to_lower_copy(text))
{ {
std::string tmp = boost::algorithm::unhex(color.second.String()); boost::algorithm::unhex(color.second.String(), std::back_inserter(rgb));
std::copy(tmp.begin(), tmp.end(), rgb);
return ColorRGBA(rgb[0], rgb[1], rgb[2]); return ColorRGBA(rgb[0], rgb[1], rgb[2]);
} }
} }

View File

@ -111,6 +111,14 @@ Extract `ccache` to a folder of your choosing, add the folder to the `PATH` envi
- Right click on `BUILD_ALL` project. This `BUILD_ALL` project should be in `CMakePredefinedTargets` tree in Solution Explorer. - 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! - VCMI will be built in `%VCMI_DIR%/build/bin` folder!
## Compile VCMI with MinGW via MSYS2
- Install MSYS2 from https://www.msys2.org/
- Start the `MSYS MinGW x64`-shell
- Install dependencies: `pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-boost mingw-w64-x86_64-gcc mingw-w64-x86_64-ninja mingw-w64-x86_64-qt5-static`
- Generate and build solution from VCMI-root dir: `cmake --preset windows-mingw-release && cmake --build --preset windows-mingw-release`
**NOTE:** This will link Qt5 statically to `VCMI_launcher.exe` and `VCMI_Mapeditor.exe`. See [PR #3421](https://github.com/vcmi/vcmi/pull/3421) for some background.
# Create VCMI installer (This step is not required for just building & development) # Create VCMI installer (This step is not required for just building & development)
Make sure NSIS is installed to default directory or have registry entry so CMake can find it. Make sure NSIS is installed to default directory or have registry entry so CMake can find it.

View File

@ -19,6 +19,8 @@
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
ResourceSet::ResourceSet() = default;
ResourceSet::ResourceSet(const JsonNode & node) ResourceSet::ResourceSet(const JsonNode & node)
{ {
for(auto i = 0; i < GameConstants::RESOURCE_QUANTITY; i++) for(auto i = 0; i < GameConstants::RESOURCE_QUANTITY; i++)

View File

@ -30,7 +30,7 @@ private:
public: public:
// read resources set from json. Format example: { "gold": 500, "wood":5 } // read resources set from json. Format example: { "gold": 500, "wood":5 }
DLL_LINKAGE ResourceSet(const JsonNode & node); DLL_LINKAGE ResourceSet(const JsonNode & node);
DLL_LINKAGE ResourceSet() = default; DLL_LINKAGE ResourceSet();
#define scalarOperator(OPSIGN) \ #define scalarOperator(OPSIGN) \