Skip to content

Commit 2caf52a

Browse files
committed
Move to VCPKG.
* Minor cleaning of CMakeLists.txt. Fix C++ warnings and Qt deprecation. * Avoid using Python from virtual environment.
1 parent e11d5ec commit 2caf52a

Some content is hidden

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

45 files changed

+536
-231
lines changed

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

+40-10
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,50 @@ on:
66
pull_request:
77
types: [opened, synchronize, reopened]
88

9+
env:
10+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
11+
912
jobs:
1013
build:
1114
runs-on: windows-2022
1215
steps:
13-
- name: Build Plugin Python
14-
id: build-plugin-python
15-
uses: ModOrganizer2/build-with-mob-action@master
16+
# https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-actions-cache
17+
- name: Export GitHub Actions cache environment variables
18+
uses: actions/github-script@v7
19+
with:
20+
script: |
21+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
22+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
23+
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
28+
- name: Install Qt
29+
uses: jurplel/install-qt-action@v3
1630
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 }}
31+
setup-python: false
32+
version: 6.7.0
33+
modules:
34+
cache: true
35+
36+
- uses: actions/checkout@v4
37+
38+
- name: "Set environmental variables"
39+
shell: bash
40+
run: |
41+
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV
42+
43+
- name: Configure Plugin Python build
44+
shell: pwsh
45+
run: |
46+
cmake --preset vs2022-windows-standalone `
47+
"-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64" `
48+
-DPLUGIN_PYTHON_TESTING=ON
49+
50+
- name: Build Plugin Python
51+
run: cmake --build vsbuild --config RelWithDebInfo --verbose `
52+
--target python-tests --target runner-tests --target proxy
53+
2354
- name: Test Plugin Python
2455
run: ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
25-
working-directory: ${{ steps.build-plugin-python.outputs.working-directory }}

CMakeLists.txt

+14-26
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(PLUGIN_PYTHON_TESTING ${BUILD_TESTING} CACHE BOOL "build tests for plugin_python")
30+
if (PLUGIN_PYTHON_TESTING)
4331
enable_testing()
4432
add_subdirectory(tests)
4533
endif()

CMakePresets.json

+73
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

+30-4
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

+1-1
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

-17
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

+3-3
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

src/mobase/wrappers/basic_classes.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
#include <format>
66

7-
#include <executableinfo.h>
8-
#include <filemapping.h>
9-
#include <guessedvalue.h>
10-
#include <idownloadmanager.h>
11-
#include <igamefeatures.h>
12-
#include <iinstallationmanager.h>
13-
#include <imodinterface.h>
14-
#include <imodrepositorybridge.h>
15-
#include <imoinfo.h>
16-
#include <iplugin.h>
17-
#include <iplugindiagnose.h>
18-
#include <iplugingame.h>
19-
#include <ipluginlist.h>
20-
#include <pluginsetting.h>
21-
#include <versioninfo.h>
7+
#include <uibase/executableinfo.h>
8+
#include <uibase/filemapping.h>
9+
#include <uibase/game_features/igamefeatures.h>
10+
#include <uibase/guessedvalue.h>
11+
#include <uibase/idownloadmanager.h>
12+
#include <uibase/iinstallationmanager.h>
13+
#include <uibase/imodinterface.h>
14+
#include <uibase/imodrepositorybridge.h>
15+
#include <uibase/imoinfo.h>
16+
#include <uibase/iplugin.h>
17+
#include <uibase/iplugindiagnose.h>
18+
#include <uibase/iplugingame.h>
19+
#include <uibase/ipluginlist.h>
20+
#include <uibase/pluginsetting.h>
21+
#include <uibase/versioninfo.h>
2222

2323
#include "../deprecation.h"
2424
#include "pyfiletree.h"

src/mobase/wrappers/game_features.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
#include "../pybind11_all.h"
66

7-
#include <ipluginlist.h>
8-
#include <isavegameinfowidget.h>
9-
10-
#include <bsainvalidation.h>
11-
#include <dataarchives.h>
12-
#include <gameplugins.h>
13-
#include <igamefeatures.h>
14-
#include <localsavegames.h>
15-
#include <moddatachecker.h>
16-
#include <moddatacontent.h>
17-
#include <savegameinfo.h>
18-
#include <scriptextender.h>
19-
#include <unmanagedmods.h>
7+
#include <uibase/ipluginlist.h>
8+
#include <uibase/isavegameinfowidget.h>
9+
10+
#include <uibase/game_features/bsainvalidation.h>
11+
#include <uibase/game_features/dataarchives.h>
12+
#include <uibase/game_features/gameplugins.h>
13+
#include <uibase/game_features/igamefeatures.h>
14+
#include <uibase/game_features/localsavegames.h>
15+
#include <uibase/game_features/moddatachecker.h>
16+
#include <uibase/game_features/moddatacontent.h>
17+
#include <uibase/game_features/savegameinfo.h>
18+
#include <uibase/game_features/scriptextender.h>
19+
#include <uibase/game_features/unmanagedmods.h>
2020

2121
#include "pyfiletree.h"
2222

src/mobase/wrappers/pyfiletree.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
#include "../pybind11_all.h"
77

8-
#include <ifiletree.h>
9-
#include <log.h>
8+
#include <uibase/ifiletree.h>
9+
#include <uibase/log.h>
1010

1111
namespace py = pybind11;
1212
using namespace MOBase;

src/mobase/wrappers/pyfiletree.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "../pybind11_all.h"
55

6-
#include <ifiletree.h>
6+
#include <uibase/ifiletree.h>
77

88
namespace pybind11 {
99
template <>

0 commit comments

Comments
 (0)