Move to VCPKG (#26)

This commit is contained in:
Mikaël Capelle
2025-05-29 11:00:43 +02:00
committed by GitHub
parent 2edac2f596
commit 58cbcda5ea
7 changed files with 217 additions and 14 deletions
+5 -2
View File
@@ -1,9 +1,13 @@
name: Build LootCLI
on:
push:
branches: master
branches: [master]
pull_request:
types: [opened, synchronize, reopened]
env:
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite
jobs:
build:
runs-on: windows-2022
@@ -11,5 +15,4 @@ jobs:
- name: Build LootCLI
uses: ModOrganizer2/build-with-mob-action@master
with:
mo2-third-parties: boost libloot
mo2-dependencies: cmake_common
+20
View File
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-case-conflict
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.5
hooks:
- id: clang-format
'types_or': [c++, c]
ci:
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
autoupdate_schedule: quarterly
submodules: false
+27 -5
View File
@@ -1,10 +1,32 @@
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()
include(CMakePackageConfigHelpers)
project(lootcli)
add_subdirectory(src)
# install the header helper
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config.cmake"
INSTALL_DESTINATION "lib/cmake/mo2-lootcli-header"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/version.h" lootcli_version)
string(REGEX MATCH "#define LOOTCLI_VERSION_STRING[ \t]*\"([0-9.]+)\"" _ ${lootcli_version})
set(lootcli_version ${CMAKE_MATCH_1})
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config-version.cmake"
VERSION "${lootcli_version}"
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config-version.cmake
DESTINATION lib/cmake/mo2-lootcli-header
)
+52
View File
@@ -0,0 +1,52 @@
{
"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"
},
{
"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"],
"name": "vs2022-windows",
"toolset": "v143"
}
],
"buildPresets": [
{
"name": "vs2022-windows",
"resolvePackageReferences": "on",
"configurePreset": "vs2022-windows"
}
],
"version": 4
}
+3
View File
@@ -0,0 +1,3 @@
@PACKAGE_INIT@
include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-lootcli-header-targets.cmake" )
+80 -7
View File
@@ -1,12 +1,85 @@
cmake_minimum_required(VERSION 3.16)
# Qt is not required, this allows us to skip building the executable and only create
# the single-header interface when using this as a VCPKG dependency
find_package(Qt6 CONFIG COMPONENTS Core)
if (Qt6_FOUND)
message(STATUS "Qt6 found, building lootcli executable")
find_package(tomlplusplus CONFIG REQUIRED)
find_package(libloot CONFIG REQUIRED)
find_package(Boost REQUIRED CONFIG COMPONENTS locale)
# avoid CMake error/warning
set_target_properties(libloot::loot PROPERTIES
MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo
MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo
)
add_executable(lootcli WIN32)
set_target_properties(lootcli PROPERTIES
CXX_STANDARD 20
WIN32_EXECUTABLE TRUE)
target_sources(lootcli
PRIVATE
game_settings.cpp
game_settings.h
lootthread.cpp
lootthread.h
main.cpp
pch.h
version.h
version.rc
${CMAKE_CURRENT_SOURCE_DIR}/../include/lootcli/lootcli.h
)
target_compile_definitions(lootcli
PRIVATE
_UNICODE UNICODE
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
target_include_directories(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_precompile_headers(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
target_link_libraries(lootcli
PRIVATE libloot::loot Boost::headers Boost::locale
tomlplusplus::tomlplusplus Qt6::Core)
mo2_configure_executable(lootcli
WARNINGS OFF
TRANSLATIONS OFF
PRIVATE_DEPENDS boost Qt::Core loot tomlplusplus)
target_include_directories(lootcli
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
if (MSVC)
target_compile_options(lootcli
PRIVATE
"/MP"
"/W4"
"/external:anglebrackets"
"/external:W0"
)
target_link_options(lootcli
PRIVATE
$<$<CONFIG:RelWithDebInfo>:/LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF>
)
target_compile_definitions(lootcli PRIVATE _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
mo2_install_target(lootcli INSTALLDIR bin/loot)
set_target_properties(lootcli PROPERTIES VS_STARTUP_PROJECT lootcli)
endif()
install(FILES
$<TARGET_FILE:lootcli>
$<TARGET_FILE:libloot::loot>
DESTINATION bin/loot)
endif()
# library to make the header available
add_library(lootcli-header INTERFACE)
target_sources(lootcli-header INTERFACE
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../include
FILES ${CMAKE_CURRENT_LIST_DIR}/../include/lootcli/lootcli.h)
add_library(mo2::lootcli-header ALIAS lootcli-header)
install(TARGETS lootcli-header EXPORT lootcliHeaderTargets FILE_SET HEADERS)
install(EXPORT lootcliHeaderTargets
FILE mo2-lootcli-header-targets.cmake
NAMESPACE mo2::
DESTINATION lib/cmake/mo2-lootcli-header
)
+30
View File
@@ -0,0 +1,30 @@
{
"dependencies": ["boost-locale", "tomlplusplus", "libloot"],
"overrides": [
{
"name": "tomlplusplus",
"version": "3.1.0"
}
],
"vcpkg-configuration": {
"default-registry": {
"kind": "git",
"repository": "https://github.com/Microsoft/vcpkg",
"baseline": "294f76666c3000630d828703e675814c05a4fd43"
},
"registries": [
{
"kind": "git",
"repository": "https://github.com/Microsoft/vcpkg",
"baseline": "294f76666c3000630d828703e675814c05a4fd43",
"packages": ["boost*", "boost-*"]
},
{
"kind": "git",
"repository": "https://github.com/ModOrganizer2/vcpkg-registry",
"baseline": "8beb2e0efa9c17dd6d17bb05288dd1e40727f673",
"packages": ["libloot"]
}
]
}
}