Skip to content

Commit aa49e9a

Browse files
committed
- add window builder
- update windows build steps in readme
1 parent ed6885e commit aa49e9a

3 files changed

Lines changed: 67 additions & 25 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
jobs:
99
build-debian-system-reproducible:
10+
if: true
1011
runs-on: ubuntu-latest
1112
container:
1213
image: debian:bookworm
@@ -39,6 +40,7 @@ jobs:
3940
[ "$hash1" = "$hash2" ] && exit 0 || exit 1
4041
4142
build-debian-conan:
43+
if: true
4244
runs-on: ubuntu-latest
4345
container:
4446
image: debian:bookworm
@@ -67,6 +69,7 @@ jobs:
6769
run: cmake --build .
6870

6971
build-fedora-system:
72+
if: true
7073
runs-on: ubuntu-latest
7174
container:
7275
image: fedora:latest
@@ -82,3 +85,32 @@ jobs:
8285

8386
- name: Build
8487
run: cmake --build ./build
88+
89+
build-windows-conan:
90+
if: true
91+
runs-on: windows-latest
92+
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- uses: TheMrMilchmann/setup-msvc-dev@v3
97+
with:
98+
arch: x64
99+
100+
- name: Install Conan
101+
id: conan
102+
uses: turtlebrowser/get-conan@main
103+
104+
- name: Init conan
105+
run: conan profile detect
106+
107+
- name: Install dependencies
108+
shell: cmd
109+
run: conan install . -of build -s build_type=Release -o *:shared=False --build=missing
110+
111+
- name: Build
112+
shell: cmd
113+
working-directory: ./build
114+
run: .\conanbuild.bat && cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DBUILD_SHARED_LIBS=1 && cmake --build . --config Release
115+
116+

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
cmake_minimum_required(VERSION 3.25)
12
project(bncsutil)
2-
cmake_minimum_required(VERSION 3.2)
33

44
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} "${PROJECT_SOURCE_DIR}/CMake/Modules")
55
message(${CMAKE_BINARY_DIR})
@@ -65,13 +65,15 @@ else()
6565
endif()
6666

6767
if (USE_SYSTEM_LIBS)
68+
message("Using system dependencies")
6869
find_package(GMP REQUIRED)
6970
target_include_directories(bncsutil PRIVATE src ${GMP_INCLUDE_DIR})
7071
target_link_libraries(bncsutil ${GMP_LIBRARIES})
7172
else()
73+
message("Using conan dependencies")
7274
find_package(gmp REQUIRED)
73-
target_include_directories(bncsutil PRIVATE src gmp:gmp)
74-
target_link_libraries(bncsutil PRIVATE gmp:gmp)
75+
target_include_directories(bncsutil PRIVATE src gmp::gmp)
76+
target_link_libraries(bncsutil PRIVATE gmp::gmp)
7577
endif()
7678

7779
set_target_properties(bncsutil PROPERTIES OUTPUT_NAME bncsutil)

README.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,60 @@ of game versions, keys, and passwords.
1313
BNCSUtil was originally written by Eric Naeseth (shadypalm88) and has since
1414
been maintained over the course of several years by the open source Battle.net community.
1515

16-
## Usage
16+
# Usage
1717
Add `bncsutil.h` to your include directory and link against `bncsutil.lib` or `libbncsutil.so`.
1818

19-
## Building
19+
# Building
2020

21-
To force a specific build (32bit or 64bit) add `-DCMAKE_GENERATOR_PLATFORM=x86` or `-DCMAKE_GENERATOR_PLATFORM=x64` to CMake flags.
21+
To force a specific build (32bit or 64bit) add `-DCMAKE_GENERATOR_PLATFORM=x86` or `-DCMAKE_GENERATOR_PLATFORM=x64` to CMake flags.
2222

23-
### Windows Visual Studio 2019
23+
Change `BUILD_SHARED_LIBS` to build the library as static or shared.
2424

25-
Version 2019 has compiler version 16, 2015 has compiler version 14.
25+
## Windows Visual Studio 2022
2626

27-
Change `-o *:shared` option if you want to link static or dynamic dependencies.
27+
Conan is used to install dependencies. GMP can't be installed as a shared library due to a bug. Mpir dependency option will be re-introduced once it is uploaded to conan index v2 (MR pending).
2828

29-
Change `BUILD_SHARED_LIBS` to build the library as static or shared.
29+
In `cmd` or Visual Studio dev console run:
3030

3131
```
32-
conan install . -if ./build -s compiler.version=16 -s arch=x86_64 -o *:shared=True
33-
cmake -G "Visual Studio 16 2019" -B./build -DBUILD_SHARED_LIBS=1 -DCMAKE_GENERATOR_PLATFORM=x64
32+
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat" x64
33+
conan install . -of build -s build_type=Release -o *:shared=False --build=missing
34+
cd build
35+
.\conanbuild.bat
36+
cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DBUILD_SHARED_LIBS=1
37+
cmake --build . --config Release
3438
```
3539

36-
### Linux
40+
Alternatively open `build/bncsutil.sln` and build from Visual Studio.
41+
42+
## Linux
3743

38-
#### Using system dependencies
39-
Instead of using conan you can link against system provided gmp. Install `libgmp-dev` on deb distros or `gmp-devel` on rpm distros. For 32bit builds, CMake will not warn you if you are missing 32bit glibc and GMP, you must install them manually first (CentOS/Fedora: `glibc-devel.i686` and `gmp-devel.i686`).
44+
### Using system dependencies
45+
Install `libgmp-dev` on deb distros or `gmp-devel` on rpm distros. For 32bit builds, CMake will not warn you if you are missing 32bit glibc and GMP, you must install them manually first (CentOS/Fedora: `glibc-devel.i686` and `gmp-devel.i686`).
4046

4147
```
4248
cmake -G "Unix Makefiles" -B./build
43-
cd build && make && make install
49+
cd build
50+
cmake --build . --target install --config Release
4451
```
4552

46-
#### Using conan
47-
If you are using pyenv or building python3 from source, make sure you have the following packages installed first:
48-
```
49-
sudo apt-get install libbz2-dev liblzma-dev
50-
```
53+
### Using conan
54+
If you are using pyenv or building python3 from source, make sure you have `libbz2-dev` and `liblzma-dev` installed first or conan will fail to unpack dependencies.
5155

5256
```
5357
conan install . -of build -s build_type=Release --build=missing
54-
cmake -G "Unix Makefiles" -B./build -DUSE_SYSTEM_LIBS=0
55-
cd build && make && make install
58+
cd build
59+
./conanbuild.sh
60+
cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DUSE_SYSTEM_LIBS=0
61+
cmake --build . --target install --config Release
5662
```
5763

58-
## Building .deb and .rpm packages
64+
## .deb and .rpm packages
5965
After invoking CMake, cd to build folder and generate them with `cpack -G "DEB"` and `cpack -G "RPM"`.
6066
You can then use `gdebi` to do a local install of .deb with automatic dependency resolution or `yum localinstall` on rpm distros. For dnf it's `dnf install <name>.rpm`.
6167

6268
Note that this is a "devel" package which also includes header files.
6369

64-
Library installs go to `/usr/lib`, include files in `/usr/include/bncsutil`.
70+
Library installs to `/usr/lib`, include files in `/usr/include/bncsutil`.
71+
72+
Packages are also avaialble for download from github releases built on Debian Bookworm and Fedora latest.

0 commit comments

Comments
 (0)