Skip to content

Commit 58cbcda

Browse files
authored
Move to VCPKG (#26)
1 parent 2edac2f commit 58cbcda

7 files changed

Lines changed: 217 additions & 14 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
name: Build LootCLI
22
on:
33
push:
4-
branches: master
4+
branches: [master]
55
pull_request:
66
types: [opened, synchronize, reopened]
7+
8+
env:
9+
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite
10+
711
jobs:
812
build:
913
runs-on: windows-2022
1014
steps:
1115
- name: Build LootCLI
1216
uses: ModOrganizer2/build-with-mob-action@master
1317
with:
14-
mo2-third-parties: boost libloot
1518
mo2-dependencies: cmake_common

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-merge-conflict
8+
- id: check-case-conflict
9+
- repo: https://github.com/pre-commit/mirrors-clang-format
10+
rev: v19.1.5
11+
hooks:
12+
- id: clang-format
13+
'types_or': [c++, c]
14+
15+
ci:
16+
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
17+
autofix_prs: true
18+
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
19+
autoupdate_schedule: quarterly
20+
submodules: false

CMakeLists.txt

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
if(DEFINED DEPENDENCIES_DIR)
4-
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
5-
else()
6-
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
7-
endif()
3+
include(CMakePackageConfigHelpers)
84

95
project(lootcli)
6+
107
add_subdirectory(src)
8+
9+
# install the header helper
10+
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
11+
"${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config.cmake"
12+
INSTALL_DESTINATION "lib/cmake/mo2-lootcli-header"
13+
NO_SET_AND_CHECK_MACRO
14+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
15+
)
16+
17+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/version.h" lootcli_version)
18+
string(REGEX MATCH "#define LOOTCLI_VERSION_STRING[ \t]*\"([0-9.]+)\"" _ ${lootcli_version})
19+
set(lootcli_version ${CMAKE_MATCH_1})
20+
21+
write_basic_package_version_file(
22+
"${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config-version.cmake"
23+
VERSION "${lootcli_version}"
24+
COMPATIBILITY AnyNewerVersion
25+
ARCH_INDEPENDENT
26+
)
27+
28+
install(FILES
29+
${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config.cmake
30+
${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config-version.cmake
31+
DESTINATION lib/cmake/mo2-lootcli-header
32+
)

CMakePresets.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
"binaryDir": "${sourceDir}/vsbuild",
27+
"architecture": {
28+
"strategy": "set",
29+
"value": "x64"
30+
},
31+
"cacheVariables": {
32+
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4",
33+
"VCPKG_TARGET_TRIPLET": {
34+
"type": "STRING",
35+
"value": "x64-windows-static-md"
36+
}
37+
},
38+
"generator": "Visual Studio 17 2022",
39+
"inherits": ["cmake-dev", "vcpkg"],
40+
"name": "vs2022-windows",
41+
"toolset": "v143"
42+
}
43+
],
44+
"buildPresets": [
45+
{
46+
"name": "vs2022-windows",
47+
"resolvePackageReferences": "on",
48+
"configurePreset": "vs2022-windows"
49+
}
50+
],
51+
"version": 4
52+
}

cmake/config.cmake.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@PACKAGE_INIT@
2+
3+
include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-lootcli-header-targets.cmake" )

src/CMakeLists.txt

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,85 @@
11
cmake_minimum_required(VERSION 3.16)
22

3+
# Qt is not required, this allows us to skip building the executable and only create
4+
# the single-header interface when using this as a VCPKG dependency
5+
6+
find_package(Qt6 CONFIG COMPONENTS Core)
7+
8+
if (Qt6_FOUND)
9+
10+
message(STATUS "Qt6 found, building lootcli executable")
11+
12+
find_package(tomlplusplus CONFIG REQUIRED)
13+
find_package(libloot CONFIG REQUIRED)
14+
find_package(Boost REQUIRED CONFIG COMPONENTS locale)
15+
16+
# avoid CMake error/warning
17+
set_target_properties(libloot::loot PROPERTIES
18+
MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo
19+
MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo
20+
)
21+
322
add_executable(lootcli WIN32)
23+
set_target_properties(lootcli PROPERTIES
24+
CXX_STANDARD 20
25+
WIN32_EXECUTABLE TRUE)
26+
target_sources(lootcli
27+
PRIVATE
28+
game_settings.cpp
29+
game_settings.h
30+
lootthread.cpp
31+
lootthread.h
32+
main.cpp
33+
pch.h
34+
version.h
35+
version.rc
36+
${CMAKE_CURRENT_SOURCE_DIR}/../include/lootcli/lootcli.h
37+
)
38+
target_compile_definitions(lootcli
39+
PRIVATE
40+
_UNICODE UNICODE
41+
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
42+
target_include_directories(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
43+
target_precompile_headers(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
44+
target_link_libraries(lootcli
45+
PRIVATE libloot::loot Boost::headers Boost::locale
46+
tomlplusplus::tomlplusplus Qt6::Core)
47+
48+
if (MSVC)
49+
target_compile_options(lootcli
50+
PRIVATE
51+
"/MP"
52+
"/W4"
53+
"/external:anglebrackets"
54+
"/external:W0"
55+
)
56+
target_link_options(lootcli
57+
PRIVATE
58+
$<$<CONFIG:RelWithDebInfo>:/LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF>
59+
)
60+
target_compile_definitions(lootcli PRIVATE _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
61+
62+
set_target_properties(lootcli PROPERTIES VS_STARTUP_PROJECT lootcli)
63+
endif()
64+
65+
install(FILES
66+
$<TARGET_FILE:lootcli>
67+
$<TARGET_FILE:libloot::loot>
68+
DESTINATION bin/loot)
69+
70+
endif()
471

5-
mo2_configure_executable(lootcli
6-
WARNINGS OFF
7-
TRANSLATIONS OFF
8-
PRIVATE_DEPENDS boost Qt::Core loot tomlplusplus)
9-
target_include_directories(lootcli
10-
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
72+
# library to make the header available
73+
add_library(lootcli-header INTERFACE)
74+
target_sources(lootcli-header INTERFACE
75+
FILE_SET HEADERS
76+
BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../include
77+
FILES ${CMAKE_CURRENT_LIST_DIR}/../include/lootcli/lootcli.h)
78+
add_library(mo2::lootcli-header ALIAS lootcli-header)
1179

12-
mo2_install_target(lootcli INSTALLDIR bin/loot)
80+
install(TARGETS lootcli-header EXPORT lootcliHeaderTargets FILE_SET HEADERS)
81+
install(EXPORT lootcliHeaderTargets
82+
FILE mo2-lootcli-header-targets.cmake
83+
NAMESPACE mo2::
84+
DESTINATION lib/cmake/mo2-lootcli-header
85+
)

vcpkg.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"dependencies": ["boost-locale", "tomlplusplus", "libloot"],
3+
"overrides": [
4+
{
5+
"name": "tomlplusplus",
6+
"version": "3.1.0"
7+
}
8+
],
9+
"vcpkg-configuration": {
10+
"default-registry": {
11+
"kind": "git",
12+
"repository": "https://github.com/Microsoft/vcpkg",
13+
"baseline": "294f76666c3000630d828703e675814c05a4fd43"
14+
},
15+
"registries": [
16+
{
17+
"kind": "git",
18+
"repository": "https://github.com/Microsoft/vcpkg",
19+
"baseline": "294f76666c3000630d828703e675814c05a4fd43",
20+
"packages": ["boost*", "boost-*"]
21+
},
22+
{
23+
"kind": "git",
24+
"repository": "https://github.com/ModOrganizer2/vcpkg-registry",
25+
"baseline": "8beb2e0efa9c17dd6d17bb05288dd1e40727f673",
26+
"packages": ["libloot"]
27+
}
28+
]
29+
}
30+
}

0 commit comments

Comments
 (0)