Skip to content

Commit 1010bfd

Browse files
authored
Move to VCPKG (#133)
1 parent 9a788c9 commit 1010bfd

Some content is hidden

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

46 files changed

+637
-256
lines changed

.github/workflows/build-and-test.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,37 @@ name: Build & Test Plugin Python
22

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

9+
env:
10+
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite
11+
912
jobs:
1013
build:
1114
runs-on: windows-2022
1215
steps:
13-
- name: Build Plugin Python
14-
id: build-plugin-python
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.12"
19+
20+
- name: Configure Plugin Python
21+
id: configure-plugin-python
1522
uses: ModOrganizer2/build-with-mob-action@master
1623
with:
17-
mo2-third-parties: gtest python spdlog boost sip pyqt pybind11
18-
mo2-dependencies: cmake_common uibase
19-
mo2-cmake-command: -DPLUGIN_PYTHON_TESTS=1 ..
20-
- name: Build Plugin Python Tests
21-
run: cmake --build vsbuild --config RelWithDebInfo -j4 --target python-tests --target runner-tests
22-
working-directory: ${{ steps.build-plugin-python.outputs.working-directory }}
24+
mo2-dependencies: uibase
25+
mo2-skip-build: true
26+
27+
- name: Build Plugin Python
28+
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
29+
run: cmake --build vsbuild --config RelWithDebInfo --verbose `
30+
--target python-tests --target runner-tests --target proxy
31+
2332
- name: Test Plugin Python
33+
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
2434
run: ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
25-
working-directory: ${{ steps.build-plugin-python.outputs.working-directory }}
35+
36+
- name: Install Plugin Python
37+
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
38+
run: cmake --build vsbuild --config RelWithDebInfo --target INSTALL

.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: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,32 @@ cmake_minimum_required(VERSION 3.16)
22

33
cmake_policy(SET CMP0144 NEW)
44

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()
10-
115
project(plugin_python CXX)
126

13-
set(PYTHON_BUILD_PATH ${PYTHON_ROOT}/PCBuild/amd64)
7+
set(Python_FIND_VIRTUALENV STANDARD)
148

15-
# find Python - lots of "Hints" since we have a weird setup
16-
set(Python_USE_STATIC_LIBS False)
17-
set(Python_INCLUDE_DIR ${PYTHON_ROOT}/Include)
18-
set(Python_EXECUTABLE ${PYTHON_BUILD_PATH}/python.exe)
19-
if (EXISTS "${PYTHON_BUILD_PATH}/python_d.exe")
20-
set(Python_EXECUTABLE ${PYTHON_BUILD_PATH}/python_d.exe)
21-
endif()
22-
file(GLOB Python_LIBRARY ${PYTHON_BUILD_PATH}/python[0-9][0-9]*.lib)
23-
find_package(Python COMPONENTS Interpreter Development REQUIRED)
9+
# find Python before include mo2-cmake, otherwise this will trigger a bunch of CMP0111
10+
# due to the imported configuration mapping variables defined in mo2.cmake
11+
find_package(Python ${MO2_PYTHON_VERSION} COMPONENTS Interpreter Development REQUIRED)
12+
find_package(pybind11 CONFIG REQUIRED)
2413

25-
# pybind11 needs uppercase (at least EXECUTABLE and LIBRARY)
26-
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
27-
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIR})
28-
set(PYTHON_LIBRARY ${Python_LIBRARY})
14+
find_package(mo2-cmake CONFIG REQUIRED)
15+
16+
get_filename_component(Python_HOME ${Python_EXECUTABLE} PATH)
17+
set(Python_DLL_DIR "${Python_HOME}/DLLs")
18+
set(Python_LIB_DIR "${Python_HOME}/Lib")
19+
20+
mo2_python_install_pyqt()
2921

3022
# useful for naming DLL, zip, etc. (3.10 -> 310)
3123
set(Python_VERSION_SHORT ${Python_VERSION_MAJOR}${Python_VERSION_MINOR})
3224

33-
# pybind11
34-
add_subdirectory(${MO2_BUILD_PATH}/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11)
35-
3625
# projects
3726
add_subdirectory(src)
38-
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT proxy)
3927

4028
# tests (if requested)
41-
set(PLUGIN_PYTHON_TESTS ${PLUGIN_PYTHON_TESTS} CACHE BOOL "build tests for plugin_python")
42-
if (PLUGIN_PYTHON_TESTS)
29+
set(BUILD_TESTING ${BUILD_TESTING} CACHE BOOL "build tests for plugin_python")
30+
if (BUILD_TESTING)
4331
enable_testing()
4432
add_subdirectory(tests)
4533
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+
}

src/mobase/CMakeLists.txt

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

3+
find_package(Qt6 COMPONENTS Core)
4+
find_package(mo2-uibase CONFIG REQUIRED)
5+
36
pybind11_add_module(mobase MODULE)
4-
mo2_configure_library(mobase
5-
SOURCE_TREE
7+
mo2_default_source_group()
8+
mo2_configure_target(mobase
9+
NO_SOURCES
610
WARNINGS 4
711
EXTERNAL_WARNINGS 4
812
AUTOMOC ON
913
TRANSLATIONS OFF
10-
PRIVATE_DEPENDS uibase Qt::Core
1114
)
12-
target_link_libraries(mobase PRIVATE pybind11::qt pybind11::utils)
15+
mo2_target_sources(mobase
16+
FOLDER src
17+
PRIVATE
18+
deprecation.cpp
19+
deprecation.h
20+
mobase.cpp
21+
pybind11_all.h
22+
)
23+
mo2_target_sources(mobase
24+
FOLDER src/wrappers
25+
PRIVATE
26+
./wrappers/basic_classes.cpp
27+
./wrappers/game_features.cpp
28+
./wrappers/known_folders.h
29+
./wrappers/pyfiletree.cpp
30+
./wrappers/pyfiletree.h
31+
./wrappers/pyplugins.cpp
32+
./wrappers/pyplugins.h
33+
./wrappers/utils.cpp
34+
./wrappers/widgets.cpp
35+
./wrappers/wrappers.cpp
36+
./wrappers/wrappers.h
37+
)
38+
target_link_libraries(mobase PRIVATE pybind11::qt pybind11::utils mo2::uibase Qt6::Core)

src/mobase/deprecation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <QCoreApplication>
99

10-
#include "log.h"
10+
#include <uibase/log.h>
1111

1212
namespace py = pybind11;
1313

src/mobase/mobase.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@
1212
#include "wrappers/pyfiletree.h"
1313
#include "wrappers/wrappers.h"
1414

15-
// TODO: remove these include (only for testing)
16-
#include <QDir>
17-
#include <QFile>
18-
#include <QWidget>
19-
#include <iplugin.h>
20-
#include <iplugindiagnose.h>
21-
#include <ipluginfilemapper.h>
22-
#include <iplugingame.h>
23-
#include <iplugininstaller.h>
24-
#include <iplugininstallersimple.h>
25-
#include <ipluginlist.h>
26-
#include <ipluginmodpage.h>
27-
#include <ipluginpreview.h>
28-
#include <iplugintool.h>
29-
#include <isavegame.h>
30-
#include <isavegameinfowidget.h>
31-
3215
using namespace MOBase;
3316
namespace py = pybind11;
3417

src/mobase/pybind11_all.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include "pybind11_utils/shared_cpp_owner.h"
1717
#include "pybind11_utils/smart_variant_wrapper.h"
1818

19-
#include <game_feature.h>
20-
#include <isavegame.h>
21-
#include <pluginrequirements.h>
19+
#include <uibase/game_features/game_feature.h>
20+
#include <uibase/isavegame.h>
21+
#include <uibase/pluginrequirements.h>
2222

2323
namespace mo2::python {
2424

0 commit comments

Comments
 (0)