Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to VCPKG. #46

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
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()
set(MO2_CMAKE_DEPRECATED_UIBASE_INCLUDE ON)

project(bsa_packer)

add_subdirectory(src)

set(BSAPACKER_TESTS ${BSAPACKER_TESTS} CACHE BOOL "build tests for bsapacker plugin")
if(BSAPACKER_TESTS)
set(BSAPACKER_TESTING ${BSAPACKER_TESTING} CACHE BOOL "build tests for bsapacker plugin")
if(BSAPACKER_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
63 changes: 63 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"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"
},
{
"cacheVariables": {
"VCPKG_MANIFEST_FEATURES": {
"type": "STRING",
"value": "testing"
}
},
"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"
}
],
"buildPresets": [
{
"name": "vs2022-windows",
"resolvePackageReferences": "on",
"configurePreset": "vs2022-windows"
}
],
"version": 4
}
2 changes: 1 addition & 1 deletion src/ArchiveAutoService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace BsaPacker
{
bool ArchiveAutoService::CreateBSA(libbsarch::bs_archive_auto* archive, const QString& archiveName, const bsa_archive_type_e type) const
bool ArchiveAutoService::CreateBSA(libbsarch::bs_archive_auto* archive, const QString& archiveName, const bsa_archive_type_e) const
{
QProgressDialog savingDialog;
savingDialog.setWindowFlags(savingDialog.windowFlags() & ~Qt::WindowCloseButtonHint);
Expand Down
16 changes: 8 additions & 8 deletions src/ArchiveBuilderHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <bsapacker/ArchiveBuilderHelper.h>

#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <ranges>

#include "SettingsService.h"

Expand Down Expand Up @@ -61,13 +61,13 @@ namespace BsaPacker
bool ArchiveBuilderHelper::isExtensionBlacklisted(const path& filepath) const
{
const auto& setting = this->m_SettingsService->GetPluginSetting(SettingsService::SETTING_BLACKLISTED_FILES).toString().toStdString();
std::set<std::string> blacklist;
boost::split(blacklist, setting, [](char c){return c == ';';});

const auto& extension = filepath.extension().string();
const auto& count = blacklist.count(extension);
const auto& result = count > 0;
return result;
const auto &extension = filepath.extension().string();
const auto count = std::ranges::count(
setting | std::views::split(' '),
extension,
[](auto r)
{ return std::string_view(r.data(), r.size()); });
return count > 0;
}

bool ArchiveBuilderHelper::doesPathContainFiles(const path& filepath, const std::vector<path::string_type>& files) const
Expand Down
24 changes: 19 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
cmake_minimum_required(VERSION 3.16)

find_package(Qt6 COMPONENTS Concurrent)
find_path(BEXT_DI_INCLUDE_DIRS "boost/di.hpp")
find_package(mo2-cmake CONFIG REQUIRED)
find_package(mo2-uibase CONFIG REQUIRED)
find_package(mo2-libbsarch CONFIG REQUIRED)
find_package(mo2-dds-header CONFIG REQUIRED)
find_package(DirectXTex CONFIG REQUIRED)

add_library(bsa_packer SHARED)
mo2_configure_plugin(bsa_packer WARNINGS OFF
PRIVATE_DEPENDS boost Qt::Concurrent libbsarch)
mo2_configure_plugin(bsa_packer WARNINGS OFF)

target_include_directories(bsa_packer
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${BOOST_DI_ROOT}/include)
target_link_libraries(bsa_packer PRIVATE mo2::uibase Qt6::Concurrent mo2::libbsarch Microsoft::DirectXTex)
target_include_directories(bsa_packer PRIVATE ${BEXT_DI_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(bsa_packer PRIVATE BSAPACKER_LIBRARY)

mo2_install_target(bsa_packer)
# need to deploy this here as MO2 does not depends on Qt6::Concurrent
install(FILES $<TARGET_FILE:Qt6::Concurrent> DESTINATION bin/dlls)

# this is done by modorganizer itself now
#
# install(FILES $<TARGET_FILE:mo2::libbsarch> DESTINATION bin/dlls)

mo2_install_plugin(bsa_packer)
2 changes: 1 addition & 1 deletion src/NullDummyPluginService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace BsaPacker
{
bool NullDummyPluginService::CreatePlugin(const QString& modPath, const QString& archiveNameBase) const
bool NullDummyPluginService::CreatePlugin([[maybe_unused]] const QString& modPath, [[maybe_unused]] const QString& archiveNameBase) const
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TextureArchiveBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace BsaPacker
this->m_Cancelled = true;
}

void TextureArchiveBuilder::DDSCallback(bsa_archive_t archive, const wchar_t* file_path, bsa_dds_info_t* dds_info, void* context)
void TextureArchiveBuilder::DDSCallback(bsa_archive_t, const wchar_t* file_path, bsa_dds_info_t* dds_info, void* context)
{
const auto& path = *static_cast<std::wstring*>(context) + L'/' + std::wstring(file_path);

Expand Down
2 changes: 1 addition & 1 deletion src/bsapacker/ArchiveBuilderFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <bsapacker/IArchiveBuilder.h>
#include <bsapacker/IArchiveBuilderHelper.h>
#include <bsapacker/IModDto.h>
#include <libbsarch.h>
#include <libbsarch/libbsarch.h>

namespace BsaPacker
{
Expand Down
2 changes: 1 addition & 1 deletion src/bsapacker/IArchiveAutoService.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef IARCHIVEAUTOSERVICE_H
#define IARCHIVEAUTOSERVICE_H

#include <bs_archive_auto.hpp>
#include <libbsarch/bs_archive_auto.hpp>
#include <bsapacker/IModDto.h>

namespace BsaPacker
Expand Down
2 changes: 1 addition & 1 deletion src/bsapacker/IArchiveBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define IARCHIVEBUILDER_H

#include <bsapacker/IEmitsValueChanged.h>
#include <bs_archive_auto.hpp>
#include <libbsarch/bs_archive_auto.hpp>

namespace BsaPacker
{
Expand Down
2 changes: 1 addition & 1 deletion src/qlibbsarch/QLibbsarch.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <libbsarch.h>
#include <libbsarch/libbsarch.h>
#include <string>
#include <stdexcept>
#include <QDebug>
Expand Down
34 changes: 34 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"dependencies": ["mo2-libbsarch", "mo2-dds-header", "directxtex", "bext-di"],
"features": {
"standalone": {
"description": "Build Standalone.",
"dependencies": ["mo2-cmake"]
},
"testing": {
"description": "Build BSA Packer tests.",
"dependencies": ["gtest"]
}
},
"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-*", "bext-*"]
},
{
"kind": "git",
"repository": "https://github.com/ModOrganizer2/vcpkg-registry",
"baseline": "b826771be1e4507f28daffa5f2d8ae0bcfa7bf13",
"packages": ["mo2-*"]
}
]
}
}