Skip to content

Commit 6465d3e

Browse files
committed
Move to VCPKG.
* Add proper CMake packaging for UIBase. * Install pdb to pdb subfolder instead of lib. * Add alias mo2::uibase target for uibase. * Use spdlog from MO2 registry. * Generate translations for UIBase. * Publish release on tag. * Add a few string methods to remove boost dependencies.
1 parent 44201d7 commit 6465d3e

98 files changed

Lines changed: 1016 additions & 155 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,92 @@ name: Build UIBase
33
on:
44
push:
55
branches: master
6+
tags:
7+
- "*"
68
pull_request:
79
types: [opened, synchronize, reopened]
810

11+
env:
12+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
13+
914
jobs:
1015
build:
1116
runs-on: windows-2022
1217
steps:
13-
- name: Build UI Base
14-
id: build-uibase
15-
uses: ModOrganizer2/build-with-mob-action@master
18+
# https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-actions-cache
19+
- name: Export GitHub Actions cache environment variables
20+
uses: actions/github-script@v7
1621
with:
17-
mo2-third-parties: gtest spdlog boost
18-
mo2-dependencies: cmake_common
19-
mo2-cmake-command: -DUIBASE_TESTS=1 ..
22+
script: |
23+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
24+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
25+
26+
- name: Install Qt
27+
uses: jurplel/install-qt-action@v3
28+
with:
29+
version: 6.7.0
30+
modules:
31+
cache: true
32+
33+
- uses: actions/checkout@v4
34+
- uses: lukka/run-vcpkg@v11
2035

21-
- name: Build UI Base Tests
22-
run: cmake --build vsbuild --config RelWithDebInfo -j4 --target uibase-tests
23-
working-directory: ${{ steps.build-uibase.outputs.working-directory }}
36+
- name: Configure UI Base build
37+
shell: pwsh
38+
run: |
39+
cmake --preset vs2022-windows `
40+
"-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64" `
41+
"-DCMAKE_INSTALL_PREFIX=install" -DUIBASE_TESTING=ON
42+
43+
# build both Debug and RelWithDebInfo for package
44+
- name: Build UI Base
45+
run: |
46+
cmake --build vsbuild --config Debug --target uibase-tests --verbose
47+
cmake --build vsbuild --config RelWithDebInfo --target uibase-tests --verbose
2448
2549
- name: Test UI Base
26-
run: ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
27-
working-directory: ${{ steps.build-uibase.outputs.working-directory }}
50+
run: |
51+
ctest --test-dir vsbuild -C Debug --output-on-failure
52+
ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
53+
54+
- name: Install UI Base
55+
run: |
56+
cmake --install vsbuild --config Debug
57+
cmake --install vsbuild --config RelWithDebInfo
58+
59+
# this tests that UI Base can be properly used as a CMake package
60+
- name: Test UI Base package
61+
run: |
62+
cmake -B build . "-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64;..\..\install\lib\cmake\"
63+
cmake --build build --config Debug
64+
cmake --build build --config Release
65+
cmake --build build --config RelWithDebInfo
66+
working-directory: tests/cmake
67+
68+
- name: Upload UI Base artifact
69+
uses: actions/upload-artifact@master
70+
with:
71+
name: uibase
72+
path: ./install
73+
74+
publish:
75+
if: github.ref_type == 'tag'
76+
needs: build
77+
runs-on: windows-2022
78+
permissions:
79+
contents: write
80+
steps:
81+
- name: Download Artifact
82+
uses: actions/download-artifact@master
83+
with:
84+
name: uibase
85+
path: ./install
86+
87+
- name: Create UI Base archive
88+
run: 7z a uibase_${{ github.ref_name }}.7z ./install/*
89+
90+
- name: Publish Release
91+
env:
92+
GH_TOKEN: ${{ github.token }}
93+
GH_REPO: ${{ github.repository }}
94+
run: gh release create --draft=false --notes="${{ github.ref_name }}" "${{ github.ref_name }}" ./uibase_${{ github.ref_name }}.7z

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ CMakeLists.txt.user
44
/*std*.log
55
/*build
66
/src/uibasetests_en.ts
7+
/install
8+
/tests/cmake/build

CMakeLists.txt

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

3+
include(CMakePackageConfigHelpers)
4+
35
project(uibase)
46

5-
if(DEFINED DEPENDENCIES_DIR)
6-
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
7-
else()
8-
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
9-
endif()
7+
find_package(mo2-cmake CONFIG REQUIRED)
108

119
add_subdirectory(src)
1210

13-
set(UIBASE_TESTS ${UIBASE_TESTS} CACHE BOOL "build tests for uibase")
14-
if (UIBASE_TESTS)
11+
mo2_set_project_to_run_from_install(uibase EXECUTABLE ${CMAKE_INSTALL_PREFIX}/bin/ModOrganizer.exe)
12+
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT uibase)
13+
14+
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
15+
"${CMAKE_CURRENT_BINARY_DIR}/mo2-uibase-config.cmake"
16+
INSTALL_DESTINATION "lib/cmake/mo2-uibase"
17+
NO_SET_AND_CHECK_MACRO
18+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
19+
)
20+
21+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/version.rc" uibase_version)
22+
string(REGEX MATCH "#define VER_FILEVERSION\\s*([0-9]+),([0-9]+),([0-9]+)" _ ${uibase_version})
23+
set(uibase_version_major ${CMAKE_MATCH_1})
24+
set(uibase_version_minor ${CMAKE_MATCH_2})
25+
set(uibase_version_patch ${CMAKE_MATCH_3})
26+
27+
write_basic_package_version_file(
28+
"${CMAKE_CURRENT_BINARY_DIR}/mo2-uibase-config-version.cmake"
29+
VERSION "${uibase_version_major}.${uibase_version_minor}.${uibase_version_patch}"
30+
COMPATIBILITY AnyNewerVersion
31+
ARCH_INDEPENDENT
32+
)
33+
34+
install(FILES
35+
${CMAKE_CURRENT_BINARY_DIR}/mo2-uibase-config.cmake
36+
${CMAKE_CURRENT_BINARY_DIR}/mo2-uibase-config-version.cmake
37+
DESTINATION lib/cmake/mo2-uibase
38+
)
39+
40+
set(UIBASE_TESTING ${UIBASE_TESTING} CACHE BOOL "build tests for uibase")
41+
if (UIBASE_TESTING)
1542
enable_testing()
1643
add_subdirectory(tests)
1744
endif()

CMakePresets.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"configurePresets": [
3+
{
4+
"errors": {
5+
"deprecated": true
6+
},
7+
"hidden": true,
8+
"name": "cmake-dev",
9+
"warnings": {
10+
"deprecated": true,
11+
"dev": true
12+
}
13+
},
14+
{
15+
"cacheVariables": {
16+
"VCPKG_MANIFEST_NO_DEFAULT_FEATURES": {
17+
"type": "BOOL",
18+
"value": "ON"
19+
}
20+
},
21+
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
22+
"hidden": true,
23+
"name": "vcpkg"
24+
},
25+
{
26+
"cacheVariables": {
27+
"VCPKG_MANIFEST_FEATURES": {
28+
"type": "STRING",
29+
"value": "testing"
30+
}
31+
},
32+
"hidden": true,
33+
"inherits": ["vcpkg"],
34+
"name": "vcpkg-dev"
35+
},
36+
{
37+
"binaryDir": "${sourceDir}/vsbuild",
38+
"architecture": {
39+
"strategy": "set",
40+
"value": "x64"
41+
},
42+
"cacheVariables": {
43+
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4",
44+
"VCPKG_TARGET_TRIPLET": {
45+
"type": "STRING",
46+
"value": "x64-windows-static-md"
47+
}
48+
},
49+
"generator": "Visual Studio 17 2022",
50+
"inherits": ["cmake-dev", "vcpkg-dev"],
51+
"name": "vs2022-windows",
52+
"toolset": "v143"
53+
}
54+
],
55+
"buildPresets": [
56+
{
57+
"name": "vs2022-windows",
58+
"resolvePackageReferences": "on",
59+
"configurePreset": "vs2022-windows"
60+
}
61+
],
62+
"version": 4
63+
}

README.md

Lines changed: 55 additions & 2 deletions

cmake/config.cmake.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@PACKAGE_INIT@
2+
3+
set(_UIBASE_PREFIX_DIR ${PACKAGE_PREFIX_DIR})
4+
5+
find_package(Qt6 CONFIG REQUIRED COMPONENTS Network QuickWidgets Widgets)
6+
7+
include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-uibase-targets.cmake" )
8+
9+
10+
if (MO2_CMAKE_DEPRECATED_UIBASE_INCLUDE)
11+
target_include_directories(mo2::uibase INTERFACE
12+
${_UIBASE_PREFIX_DIR}/include/uibase ${_UIBASE_PREFIX_DIR}/include/uibase/game_features)
13+
endif()

0 commit comments

Comments
 (0)