Skip to content

Commit d8f9c4e

Browse files
committed
feat: move to vcpkg
1 parent 98a71ea commit d8f9c4e

24 files changed

Lines changed: 72 additions & 37451 deletions

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build Mob
22

33
on:
44
push:
5-
branches: master
5+
branches: [master]
66
pull_request:
77
types: [opened, synchronize, reopened]
88

@@ -13,4 +13,6 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- name: Build Mob
1515
shell: pwsh
16-
run: ./bootstrap.ps1 -Verbose
16+
run: |
17+
$env:VCPKG_ROOT = $env:VCPKG_INSTALLATION_ROOT
18+
./bootstrap.ps1 -Verbose

bootstrap.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ if (!$root) {
1313

1414
$output = if ($Verbose) { "Out-Default" } else { "Out-Null" }
1515

16-
cmake -B $root/build -G "Visual Studio 17 2022" $root | & $output
16+
cmake -B $root/build -G "Visual Studio 17 2022" -A x64 `
17+
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
18+
-DVCPKG_TARGET_TRIPLET=x64-windows-static-md `
19+
$root | & $output
1720

1821
$installationPath = & $root\third-party\bin\vswhere.exe -products * -nologo -prerelease -latest -property installationPath
1922
if (! $?) {

custom-ports/zlib/portfile.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

custom-ports/zlib/vcpkg.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
3+
"name": "zlib",
4+
"version-string": "zlib-ng overlay",
5+
"dependencies": [
6+
"zlib-ng"
7+
]
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(VCPKG_TARGET_ARCHITECTURE x64)
2+
set(VCPKG_CRT_LINKAGE dynamic)
3+
set(VCPKG_LIBRARY_LINKAGE static)
4+
5+
set(ZLIB_COMPAT ON)

readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ check the [ModOrganizer2 Wiki](https://github.com/ModOrganizer2/modorganizer/wik
3333
```powershell
3434
git clone https://github.com/ModOrganizer2/mob
3535
cd mob
36+
$env:VCPKG_ROOT = "C:\path\to\vcpkg"
3637
./bootstrap
3738
mob -d c:\somewhere build
3839
```
@@ -108,6 +109,20 @@ aqt install-qt --outputdir "C:\Qt" windows desktop ${QT_VERSION} win64_msvc2022_
108109
- Git for Windows (Skip if you have this already installed outside of the VS installer)
109110
- CMake tools for Windows (Skip if you have this already installed outside of the VS installer)
110111

112+
### vcpkg
113+
114+
`mob` now uses **vcpkg** to manage its third-party dependencies (like libcurl).
115+
116+
1. **Install vcpkg**: If you don't have it, follow the [official instructions](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started).
117+
2. **Set Environment Variable**: `mob` requires the `VCPKG_ROOT` environment variable to locate the toolchain.
118+
119+
```powershell
120+
$env:VCPKG_ROOT = "C:\path\to\vcpkg"
121+
$env:PATH = "$env:VCPKG_ROOT;$env:PATH"
122+
```
123+
124+
3. **Static Triplet**: `mob` builds with the `x64-windows-static-md` triplet by default to ensure a standalone executable. The `bootstrap.ps1` script handles this automatically if `VCPKG_ROOT` is set.
125+
111126
## Setting up MOB
112127

113128
```powershell
@@ -117,6 +132,9 @@ cd C:\dev
117132
# clone this repository
118133
git clone https://github.com/ModOrganizer2/mob
119134
135+
# set vcpkg path, or use `vcpkg integrate install` instead
136+
$env:VCPKG_ROOT = "C:\path\to\your\vcpkg"
137+
120138
# build mob itself - this will create mob.exe in the current directory
121139
./bootstrap.ps1
122140

src/CMakeLists.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
cmake_minimum_required(VERSION 3.16)
22

3+
find_package(clipp CONFIG REQUIRED)
4+
find_package(nlohmann_json CONFIG REQUIRED)
5+
find_package(CURL REQUIRED)
6+
37
file(GLOB_RECURSE source_files *.cpp)
48
file(GLOB_RECURSE header_files *.h)
59

610
add_executable(mob ${source_files} ${header_files})
711
set_target_properties(mob PROPERTIES CXX_STANDARD 20)
812

9-
target_compile_definitions(mob PUBLIC NOMINMAX)
10-
target_compile_options(mob PUBLIC "/MT")
11-
target_include_directories(mob PUBLIC ${CMAKE_SOURCE_DIR}/third-party/include)
12-
target_link_libraries(mob PUBLIC
13-
wsock32 ws2_32 crypt32 wldap32 dbghelp shlwapi version
14-
optimized ${CMAKE_SOURCE_DIR}/third-party/lib/libcurl.lib
15-
debug ${CMAKE_SOURCE_DIR}/third-party/lib/libcurl-d.lib
16-
optimized ${CMAKE_SOURCE_DIR}/third-party/lib/zlib.lib
17-
debug ${CMAKE_SOURCE_DIR}/third-party/lib/zlibd.lib)
13+
target_compile_definitions(mob PRIVATE NOMINMAX)
14+
15+
target_link_libraries(mob PRIVATE clipp::clipp nlohmann_json::nlohmann_json
16+
CURL::libcurl dbghelp shlwapi version)
1817

19-
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}
20-
PREFIX src
21-
FILES ${source_files} ${header_files})
18+
source_group(
19+
TREE ${CMAKE_CURRENT_SOURCE_DIR}
20+
PREFIX src
21+
FILES ${source_files} ${header_files})
2222
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT mob)

0 commit comments

Comments
 (0)