From 2fd5f8c8d428f75d23f105fac81575c0d26ba887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Fri, 12 Jul 2024 16:12:53 +0200 Subject: [PATCH] Move to VCPKG. --- .github/workflows/build.yml | 40 +++++++++++++++++++++---- CMakeLists.txt | 6 ---- CMakePresets.json | 60 +++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 14 +++++++-- src/previewbsa.cpp | 12 ++++---- src/previewbsa.h | 5 ++-- src/simplefiletreemodel.cpp | 3 +- src/simplefiletreemodel.h | 3 +- vcpkg.json | 38 +++++++++++++++++++++++ 9 files changed, 157 insertions(+), 24 deletions(-) create mode 100644 CMakePresets.json create mode 100644 vcpkg.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ad948d..5abbbeb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Preview BSA Plugin +name: Build Preview BSA on: push: @@ -6,12 +6,42 @@ on: pull_request: types: [opened, synchronize, reopened] +env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + jobs: build: runs-on: windows-2022 steps: - - name: Build Preview BSA Plugin - uses: ModOrganizer2/build-with-mob-action@master + # https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-actions-cache + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Install Qt + uses: jurplel/install-qt-action@v3 with: - mo2-third-parties: zlib boost lz4 DirectXTex - mo2-dependencies: cmake_common uibase bsatk + setup-python: false + version: 6.7.0 + modules: + cache: true + + - uses: actions/checkout@v4 + + - name: "Set environmental variables" + shell: bash + run: | + echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV + + - name: Configure Preview BSA + shell: pwsh + run: | + cmake --preset vs2022-windows-standalone ` + "-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64" ` + "-DCMAKE_INSTALL_PREFIX=install" + + - name: Build Preview BSA + run: cmake --build vsbuild --config RelWithDebInfo --target INSTALL diff --git a/CMakeLists.txt b/CMakeLists.txt index 062d4ca..e7757aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,4 @@ cmake_minimum_required(VERSION 3.16) -if(DEFINED DEPENDENCIES_DIR) - include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake) -else() - include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake) -endif() - project(preview_bsa) add_subdirectory(src) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..16e1e6f --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,60 @@ +{ + "configurePresets": [ + { + "errors": { + "deprecated": true + }, + "hidden": true, + "name": "cmake-dev", + "warnings": { + "deprecated": true, + "dev": true + } + }, + { + "cacheVariables": { + "VCPKG_MANIFEST_NO_DEFAULT_FEATURES": { + "type": "BOOL", + "value": "ON" + } + }, + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "hidden": true, + "name": "vcpkg" + }, + { + "hidden": true, + "inherits": ["vcpkg"], + "name": "vcpkg-dev" + }, + { + "binaryDir": "${sourceDir}/vsbuild", + "architecture": { + "strategy": "set", + "value": "x64" + }, + "cacheVariables": { + "CMAKE_CXX_FLAGS": "/EHsc /MP /W4", + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "x64-windows-static-md" + } + }, + "generator": "Visual Studio 17 2022", + "inherits": ["cmake-dev", "vcpkg-dev"], + "name": "vs2022-windows", + "toolset": "v143" + }, + { + "cacheVariables": { + "VCPKG_MANIFEST_FEATURES": { + "type": "STRING", + "value": "standalone" + } + }, + "inherits": "vs2022-windows", + "name": "vs2022-windows-standalone" + } + ], + "version": 4 +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2de2e57..b9c2c5b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,15 @@ cmake_minimum_required(VERSION 3.16) +find_package(mo2-cmake CONFIG REQUIRED) +find_package(mo2-uibase CONFIG REQUIRED) + +find_package(ZLIB REQUIRED) +find_package(lz4 CONFIG REQUIRED) +find_package(Boost CONFIG REQUIRED COMPONENTS thread interprocess) +find_package(mo2-dds-header CONFIG REQUIRED) +find_package(mo2-bsatk CONFIG REQUIRED) + add_library(preview_bsa SHARED) -mo2_configure_plugin(preview_bsa WARNINGS OFF PRIVATE_DEPENDS DirectXTex bsatk) -mo2_install_target(preview_bsa) +mo2_configure_plugin(preview_bsa WARNINGS 4) +target_link_libraries(preview_bsa PRIVATE mo2::uibase mo2::bsatk) +mo2_install_plugin(preview_bsa) diff --git a/src/previewbsa.cpp b/src/previewbsa.cpp index 6a467ed..9919981 100644 --- a/src/previewbsa.cpp +++ b/src/previewbsa.cpp @@ -16,10 +16,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Bsa Preview plugin. If not, see . */ -#define QT - #include "previewbsa.h" -#include "simplefiletreemodel.h" + #include #include #include @@ -32,10 +30,12 @@ along with Bsa Preview plugin. If not, see . #include #include #include -#include -#include -#include +#include +#include +#include + +#include "simplefiletreemodel.h" using namespace MOBase; diff --git a/src/previewbsa.h b/src/previewbsa.h index 7981d89..6c3ee2e 100644 --- a/src/previewbsa.h +++ b/src/previewbsa.h @@ -21,9 +21,10 @@ along with bsa Preview plugin. If not, see . #define PREVIEWBSA_H #include -#include -#include +#include + +#include class PreviewBsa : public MOBase::IPluginPreview { diff --git a/src/simplefiletreemodel.cpp b/src/simplefiletreemodel.cpp index 428cc69..311564c 100644 --- a/src/simplefiletreemodel.cpp +++ b/src/simplefiletreemodel.cpp @@ -121,8 +121,7 @@ int SimpleFileTreeModel::rowCount(const QModelIndex& parent) const return parentItem->childCount(); } -void SimpleFileTreeModel::setupModelData(const QStringList& lines, - SimpleFileTreeItem* parent) +void SimpleFileTreeModel::setupModelData(const QStringList& lines, SimpleFileTreeItem*) { for (QString line : lines) { auto fullPath = QDir::cleanPath(line); diff --git a/src/simplefiletreemodel.h b/src/simplefiletreemodel.h index 4124cd2..5189d89 100644 --- a/src/simplefiletreemodel.h +++ b/src/simplefiletreemodel.h @@ -6,7 +6,8 @@ #include #include #include -#include + +#include using namespace MOBase; diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..cd0258e --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,38 @@ +{ + "dependencies": [ + "mo2-cmake", + "mo2-dds-header", + "zlib", + "lz4", + "mo2-dds-header", + "boost-interprocess", + "boost-thread" + ], + "features": { + "standalone": { + "description": "Build Standalone.", + "dependencies": ["mo2-uibase", "mo2-bsatk"] + } + }, + "vcpkg-configuration": { + "default-registry": { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7" + }, + "registries": [ + { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7", + "packages": ["boost*", "boost-*"] + }, + { + "kind": "git", + "repository": "https://github.com/ModOrganizer2/vcpkg-registry", + "baseline": "70c0aacd6962073dae6e46c2e810c91aa755d2e2", + "packages": ["mo2-*", "pybind11", "spdlog"] + } + ] + } +}