Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'windows-mingw-release' CMake preset #3421

Merged
merged 8 commits into from
Jan 4, 2024
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ if(ENABLE_CCACHE)
find_program(CCACHE ccache REQUIRED)
endif()

# On Linux, use ccache via CMAKE_CXX_COMPILER_LAUNCHER.
# 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_CXX_COMPILER_LAUNCHER "ccache")
endif()
Expand Down
19 changes: 19 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@
"CMAKE_CXX_COMPILER": "/usr/bin/g++"
}
},
{
"name": "windows-mingw-release",
kambala-decapitator marked this conversation as resolved.
Show resolved Hide resolved
"displayName": "Windows x64 MinGW Release",
"description": "VCMI Windows Ninja using MinGW",
"inherits": "default-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "windows-msvc-release",
"displayName": "Windows x64 RelWithDebInfo",
Expand Down Expand Up @@ -352,6 +361,11 @@
"configurePreset": "macos-arm-conan-ninja-release",
"inherits": "default-release"
},
{
"name": "windows-mingw-release",
"configurePreset": "windows-mingw-release",
"inherits": "default-release"
},
{
"name": "windows-msvc-release",
"configurePreset": "windows-msvc-release",
Expand Down Expand Up @@ -438,6 +452,11 @@
"configurePreset": "macos-ninja-release",
"inherits": "default-release"
},
{
"name": "windows-mingw-release",
"configurePreset": "windows-mingw-release",
"inherits": "default-release"
},
{
"name": "windows-msvc-release",
"configurePreset": "windows-msvc-release",
Expand Down
9 changes: 4 additions & 5 deletions client/render/Colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ std::optional<ColorRGBA> Colors::parseColor(std::string text)
{
std::smatch match;
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))
{
std::string tmp = boost::algorithm::unhex(match[1].str());
std::copy(tmp.begin(), tmp.end(), rgb);
boost::algorithm::unhex(match[1].str(), std::back_inserter(rgb));
return ColorRGBA(rgb[0], rgb[1], rgb[2]);
}

Expand All @@ -42,8 +42,7 @@ std::optional<ColorRGBA> Colors::parseColor(std::string text)
for(auto & color : colors) {
if(boost::algorithm::to_lower_copy(color.first) == boost::algorithm::to_lower_copy(text))
{
std::string tmp = boost::algorithm::unhex(color.second.String());
std::copy(tmp.begin(), tmp.end(), rgb);
boost::algorithm::unhex(color.second.String(), std::back_inserter(rgb));
return ColorRGBA(rgb[0], rgb[1], rgb[2]);
}
}
Expand Down
8 changes: 8 additions & 0 deletions docs/developers/Building_Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- 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)

Make sure NSIS is installed to default directory or have registry entry so CMake can find it.
Expand Down
2 changes: 2 additions & 0 deletions lib/ResourceSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

VCMI_LIB_NAMESPACE_BEGIN

ResourceSet::ResourceSet() = default;

ResourceSet::ResourceSet(const JsonNode & node)
{
for(auto i = 0; i < GameConstants::RESOURCE_QUANTITY; i++)
Expand Down
2 changes: 1 addition & 1 deletion lib/ResourceSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ResourceSet
public:
// read resources set from json. Format example: { "gold": 500, "wood":5 }
DLL_LINKAGE ResourceSet(const JsonNode & node);
DLL_LINKAGE ResourceSet() = default;
DLL_LINKAGE ResourceSet();


#define scalarOperator(OPSIGN) \
Expand Down
Loading