From 8c88088e6b135e8677a0f86a089c141a4ac1ca21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Fri, 12 Jul 2024 15:48:26 +0200 Subject: [PATCH] Move to VCPKG. --- .github/workflows/build.yml | 39 +++++++++++++++++++++--- CMakeLists.txt | 7 +---- CMakePresets.json | 60 +++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 10 +++++-- src/preview_base_en.ts | 8 ++--- src/previewbase.cpp | 4 ++- src/previewbase.h | 7 ++--- src/previewbase.json | 1 - vcpkg.json | 24 +++++++++++++++ 9 files changed, 137 insertions(+), 23 deletions(-) create mode 100644 CMakePresets.json delete mode 100644 src/previewbase.json create mode 100644 vcpkg.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16ace70..036c60c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Preview Base Plugin +name: Build Preview Base on: push: @@ -6,11 +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 Base 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-dependencies: cmake_common uibase + 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 Base + shell: pwsh + run: | + cmake --preset vs2022-windows-standalone ` + "-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64" ` + "-DCMAKE_INSTALL_PREFIX=install" + + - name: Build Preview Base + run: cmake --build vsbuild --config RelWithDebInfo --target INSTALL diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d0df9..e8897ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,5 @@ 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_base) + 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 ac53ddf..cceaf3f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.16) -add_library(preview_base SHARED) -mo2_configure_plugin(preview_base WARNINGS OFF) -mo2_install_target(preview_base) +find_package(mo2-cmake CONFIG REQUIRED) +find_package(mo2-uibase CONFIG REQUIRED) + +add_library(preview_base SHARED previewbase.cpp previewbase.h) +mo2_configure_plugin(preview_base NO_SOURCES WARNINGS 4) +target_link_libraries(preview_base PRIVATE mo2::uibase) +mo2_install_plugin(preview_base) diff --git a/src/preview_base_en.ts b/src/preview_base_en.ts index 27fb091..3c66964 100644 --- a/src/preview_base_en.ts +++ b/src/preview_base_en.ts @@ -4,22 +4,22 @@ PreviewBase - + Preview Base - + Supports previewing various types of data files - + Enable previewing of basic file types, such as images and text files. - + Specify a list of comma separated extensions (without ".") that should not be previewed by this plugin. diff --git a/src/previewbase.cpp b/src/previewbase.cpp index ff8be88..cd393d8 100644 --- a/src/previewbase.cpp +++ b/src/previewbase.cpp @@ -18,6 +18,7 @@ along with Base Preview plugin. If not, see . */ #include "previewbase.h" + #include #include #include @@ -25,7 +26,8 @@ along with Base Preview plugin. If not, see . #include #include #include -#include + +#include using namespace MOBase; diff --git a/src/previewbase.h b/src/previewbase.h index 09576a6..d4ffc14 100644 --- a/src/previewbase.h +++ b/src/previewbase.h @@ -21,16 +21,15 @@ along with Base Preview plugin. If not, see . #define PREVIEWBASE_H #include -#include + +#include class PreviewBase : public MOBase::IPluginPreview { Q_OBJECT Q_INTERFACES(MOBase::IPlugin MOBase::IPluginPreview) -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - Q_PLUGIN_METADATA(IID "org.tannin.PreviewBase" FILE "previewbase.json") -#endif + Q_PLUGIN_METADATA(IID "org.tannin.PreviewBase") public: PreviewBase(); diff --git a/src/previewbase.json b/src/previewbase.json deleted file mode 100644 index 69a88e3..0000000 --- a/src/previewbase.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..980401d --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,24 @@ +{ + "dependencies": ["mo2-cmake"], + "features": { + "standalone": { + "description": "Build Standalone.", + "dependencies": ["mo2-uibase"] + } + }, + "vcpkg-configuration": { + "default-registry": { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7" + }, + "registries": [ + { + "kind": "git", + "repository": "https://github.com/ModOrganizer2/vcpkg-registry", + "baseline": "1fe57e2a569f00526fa8f7347282a646148f362b", + "packages": ["mo2-*"] + } + ] + } +}