Skip to content

Commit 96a2f3a

Browse files
authored
Move to VCPKG (#155)
* Add proper CMake packaging for UIBase. * Add alias mo2::uibase target for uibase. * Add a few string methods to remove boost dependencies.
1 parent f69e82b commit 96a2f3a

107 files changed

Lines changed: 1641 additions & 198 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: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,78 @@ name: Build UIBase
22

33
on:
44
push:
5-
branches: master
5+
branches: [master]
6+
tags:
7+
- "*"
68
pull_request:
79
types: [opened, synchronize, reopened]
810

11+
env:
12+
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite
13+
914
jobs:
1015
build:
1116
runs-on: windows-2022
1217
steps:
13-
- name: Build UI Base
14-
id: build-uibase
18+
- name: Configure UIBase
19+
id: configure-uibase
1520
uses: ModOrganizer2/build-with-mob-action@master
1621
with:
17-
mo2-third-parties: gtest spdlog boost
18-
mo2-dependencies: cmake_common
19-
mo2-cmake-command: -DUIBASE_TESTS=1 ..
22+
# skip build because we are going to build both Debug and RelWithDebInfo here
23+
mo2-skip-build: true
2024

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 }}
25+
# build both Debug and RelWithDebInfo for package
26+
- name: Build UI Base
27+
working-directory: ${{ steps.configure-uibase.outputs.working-directory }}
28+
run: |
29+
cmake --build vsbuild --config Debug --target uibase-tests --verbose
30+
cmake --build vsbuild --config RelWithDebInfo --target uibase-tests --verbose
2431
2532
- name: Test UI Base
26-
run: ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
27-
working-directory: ${{ steps.build-uibase.outputs.working-directory }}
33+
working-directory: ${{ steps.configure-uibase.outputs.working-directory }}
34+
run: |
35+
ctest --test-dir vsbuild -C Debug --output-on-failure
36+
ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
37+
38+
- name: Install UI Base
39+
working-directory: ${{ steps.configure-uibase.outputs.working-directory }}
40+
run: |
41+
cmake --install vsbuild --config Debug
42+
cmake --install vsbuild --config RelWithDebInfo
43+
44+
# this tests that UI Base can be properly used as a CMake package
45+
- name: Test UI Base package
46+
run: |
47+
cmake -B build . "-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2022_64;${{ github.workspace }}\install\lib\cmake\"
48+
cmake --build build --config Debug
49+
cmake --build build --config Release
50+
cmake --build build --config RelWithDebInfo
51+
working-directory: ${{ steps.configure-uibase.outputs.working-directory }}/tests/cmake
52+
53+
- name: Upload UI Base artifact
54+
uses: actions/upload-artifact@master
55+
with:
56+
name: uibase
57+
path: ./install
58+
59+
publish:
60+
if: github.ref_type == 'tag'
61+
needs: build
62+
runs-on: windows-2022
63+
permissions:
64+
contents: write
65+
steps:
66+
- name: Download Artifact
67+
uses: actions/download-artifact@master
68+
with:
69+
name: uibase
70+
path: ./install
71+
72+
- name: Create UI Base archive
73+
run: 7z a uibase_${{ github.ref_name }}.7z ./install/*
74+
75+
- name: Publish Release
76+
env:
77+
GH_TOKEN: ${{ github.token }}
78+
GH_REPO: ${{ github.repository }}
79+
run: gh release create --draft=false --notes="${{ github.ref_name }}" "${{ github.ref_name }}" ./uibase_${{ github.ref_name }}.7z

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
edit
2+
.vscode
23
CMakeLists.txt.user
34
/msbuild.log
45
/*std*.log
56
/*build
67
/src/uibasetests_en.ts
8+
/install
9+
/tests/cmake/build

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-merge-conflict
8+
- id: check-case-conflict
9+
- repo: https://github.com/pre-commit/mirrors-clang-format
10+
rev: v19.1.5
11+
hooks:
12+
- id: clang-format
13+
'types_or': [c++, c]
14+
15+
ci:
16+
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
17+
autofix_prs: true
18+
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
19+
autoupdate_schedule: quarterly
20+
submodules: false

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(BUILD_TESTING ${BUILD_TESTING} CACHE BOOL "build tests for uibase")
41+
if (BUILD_TESTING)
1542
enable_testing()
1643
add_subdirectory(tests)
1744
endif()

CMakePresets.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
"cacheVariables": {
56+
"VCPKG_MANIFEST_FEATURES": {
57+
"type": "STRING",
58+
"value": "standalone;testing"
59+
}
60+
},
61+
"inherits": "vs2022-windows",
62+
"name": "vs2022-windows-standalone"
63+
}
64+
],
65+
"buildPresets": [
66+
{
67+
"name": "vs2022-windows",
68+
"resolvePackageReferences": "on",
69+
"configurePreset": "vs2022-windows"
70+
}
71+
],
72+
"version": 4
73+
}

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)