Skip to content

Commit 19dfe89

Browse files
Update template
1 parent b3541af commit 19dfe89

File tree

7 files changed

+1242
-108
lines changed

7 files changed

+1242
-108
lines changed

.github/workflows/testbuild.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
types: completed
77
workflow_dispatch:
88

9-
env:
10-
VCPKG_COMMIT_ID: e44d60e6bf0964064bf69667cd9f3e91dc383c7c
11-
129
jobs:
1310
test-build:
1411
runs-on: windows-latest
@@ -18,20 +15,23 @@ jobs:
1815
preset:
1916
- debug
2017
- release
18+
compiler:
19+
- msvc
20+
- clang-cl
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424

2525
- name: Get CMake
2626
uses: lukka/get-cmake@latest
2727

28-
- name: Setup vcpkg
29-
uses: lukka/[email protected]
28+
- name: Setup MSVC prompt
29+
uses: TheMrMilchmann/setup-msvc-dev@v3
3030
with:
31-
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
31+
arch: x64
32+
toolset: 14.38
3233

33-
- name: Run CMake
34-
uses: lukka/[email protected]
35-
with:
36-
configurePreset: build-${{ matrix.preset }}-msvc
37-
buildPreset: ${{ matrix.preset }}-msvc
34+
- name: Build
35+
run: |
36+
cmake -B ./build --preset=build-${{ matrix.preset }}-${{ matrix.compiler }}
37+
cmake --build ./build --preset=${{ matrix.preset }}-${{ matrix.compiler }}

CMakeLists.txt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
cmake_minimum_required(VERSION 3.27)
2-
message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.")
32

43
########################################################################################################################
54
## Define project
@@ -17,6 +16,13 @@ set(CMAKE_OPTIMIZE_DEPENDENCIES ON)
1716

1817
include(GNUInstallDirs)
1918

19+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")
20+
21+
CPMAddPackage("gh:Starfield-Reverse-Engineering/CommonLibSF#main")
22+
CPMAddPackage("gh:brofield/[email protected]")
23+
24+
include("${CommonLibSF_SOURCE_DIR}/CommonLibSF/cmake/CommonLibSF.cmake")
25+
2026
configure_file(
2127
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in
2228
${CMAKE_CURRENT_BINARY_DIR}/version.rc
@@ -47,8 +53,6 @@ source_group(
4753
########################################################################################################################
4854
## Configure target DLL
4955
########################################################################################################################
50-
find_package(CommonLibSF CONFIG REQUIRED)
51-
5256
add_commonlibsf_plugin(
5357
${PROJECT_NAME}
5458
AUTHOR AuthorName
@@ -57,15 +61,13 @@ add_commonlibsf_plugin(
5761

5862
add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}")
5963

60-
find_path(SIMPLEINI_INCLUDE_DIRS "SimpleIni.h")
61-
6264
target_include_directories(
6365
${PROJECT_NAME}
6466
PRIVATE
6567
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
6668
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>
6769
$<INSTALL_INTERFACE:src>
68-
${SIMPLEINI_INCLUDE_DIRS}
70+
${SimpleIni_SOURCE_DIR}
6971
PUBLIC
7072
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
7173
)
@@ -74,7 +76,7 @@ target_precompile_headers(
7476
${PROJECT_NAME}
7577
PRIVATE
7678
include/PCH.h
77-
${SIMPLEINI_INCLUDE_DIRS}/SimpleIni.h
79+
${SimpleIni_SOURCE_DIR}/SimpleIni.h
7880
)
7981

8082
install(
@@ -132,3 +134,7 @@ set_property(
132134
TARGET ${PROJECT_NAME}
133135
APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${OUTPUT_PDBS}"
134136
)
137+
set_property(
138+
TARGET ${PROJECT_NAME}
139+
APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/build/.cpm"
140+
)

CMakePresets.json

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,8 @@
1212
"cacheVariables": {
1313
"CMAKE_CXX_FLAGS": "$env{COMMONLIBSF_COMPILER} $env{COMMONLIBSF_PLATFORM} $penv{CXXFLAGS}",
1414
"CMAKE_SHARED_LINKER_FLAGS": "$env{COMMONLIBSF_LINKER} $penv{SHARED_LINKER_FLAGS}",
15-
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
16-
}
17-
},
18-
{
19-
"name": "vcpkg",
20-
"hidden": true,
21-
"cacheVariables": {
22-
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
23-
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md",
24-
"VCPKG_HOST_TRIPLET": "x64-windows-static-md"
15+
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
16+
"CPM_SOURCE_CACHE": "${sourceDir}/build/.cpm"
2517
}
2618
},
2719
{
@@ -39,6 +31,25 @@
3931
"strategy": "external"
4032
}
4133
},
34+
{
35+
"name": "clang-cl",
36+
"hidden": true,
37+
"generator": "Ninja",
38+
"cmakeExecutable": "C:/Program Files/CMake/bin/",
39+
"cacheVariables": {
40+
"CMAKE_CXX_COMPILER": "clang-cl"
41+
},
42+
"environment": {
43+
"COMMONLIBSF_COMPILER": "/cgthreads8 /diagnostics:caret /EHsc /fp:contract /fp:except- /guard:cf- /permissive- /sdl /W4 /Zc:__cplusplus /Zc:rvalueCast /Zc:ternary -Wno-unused-private-field -Wno-unused-parameter -Wno-overloaded-virtual -Wno-delete-non-abstract-non-virtual-dtor -Wno-unused-command-line-argument"
44+
},
45+
"vendor": {
46+
"microsoft.com/VisualStudioSettings/CMake/1.0": {
47+
"intelliSenseMode": "windows-clang-x64",
48+
"enableMicrosoftCodeAnalysis": true,
49+
"enableClangTidyCodeAnalysis": true
50+
}
51+
}
52+
},
4253
{
4354
"name": "msvc",
4455
"hidden": true,
@@ -55,9 +66,30 @@
5566
}
5667
}
5768
},
69+
{
70+
"name": "build-release-clang-cl",
71+
"inherits": [ "base", "win32", "x64", "clang-cl" ],
72+
"cacheVariables": {
73+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
74+
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/fp:fast /GR- /Gw /O2"
75+
},
76+
"displayName": "Release",
77+
"description": "Optimized release build.",
78+
"binaryDir": "${sourceDir}/build/release-clang-cl"
79+
},
80+
{
81+
"name": "build-debug-clang-cl",
82+
"inherits": [ "base", "win32", "x64", "clang-cl" ],
83+
"cacheVariables": {
84+
"CMAKE_BUILD_TYPE": "Debug"
85+
},
86+
"displayName": "Debug",
87+
"description": "Debug build.",
88+
"binaryDir": "${sourceDir}/build/debug-clang-cl"
89+
},
5890
{
5991
"name": "build-release-msvc",
60-
"inherits": ["base", "vcpkg", "win32", "x64", "msvc"],
92+
"inherits": [ "base", "win32", "x64", "msvc" ],
6193
"cacheVariables": {
6294
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
6395
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/fp:fast /GR- /Gw /O2 /Ob3 /Qpar",
@@ -69,7 +101,7 @@
69101
},
70102
{
71103
"name": "build-debug-msvc",
72-
"inherits": ["base", "vcpkg", "win32", "x64", "msvc"],
104+
"inherits": [ "base", "win32", "x64", "msvc" ],
73105
"cacheVariables": {
74106
"CMAKE_BUILD_TYPE": "Debug",
75107
"CMAKE_SHARED_LINKER_FLAGS_DEBUG": "/DEBUGTYPE:FIXUP"
@@ -80,15 +112,27 @@
80112
}
81113
],
82114
"buildPresets": [
115+
{
116+
"name": "release-clang-cl",
117+
"displayName": "1. Release (clang-cl)",
118+
"configurePreset": "build-release-clang-cl",
119+
"description": "Optimized release build."
120+
},
121+
{
122+
"name": "debug-clang-cl",
123+
"displayName": "2. Debug (clang-cl)",
124+
"configurePreset": "build-debug-clang-cl",
125+
"description": "Debug build."
126+
},
83127
{
84128
"name": "release-msvc",
85-
"displayName": "1. Release (MSVC)",
129+
"displayName": "3. Release (MSVC)",
86130
"configurePreset": "build-release-msvc",
87131
"description": "Optimized release build."
88132
},
89133
{
90134
"name": "debug-msvc",
91-
"displayName": "2. Debug (MSVC)",
135+
"displayName": "4. Debug (MSVC)",
92136
"configurePreset": "build-debug-msvc",
93137
"description": "Debug build."
94138
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
## Setup
99

10-
This template consumes CommonLibSF either as a vcpkg port or as a git submodule. When you run the project setup script, you will be prompted to choose between the two (the default is via vcpkg).
10+
This template consumes CommonLibSF as a CPM.cmake package, a git submodule, or a local fork. When you run the project setup script, you will be prompted to choose between the three (default is as a CPM package).
1111

1212
A python script, `project_setup.py`, is provided which automates several housekeeping steps required to get the template development-ready (requires [Python](https://www.python.org/download)). To run the script:
1313

1414
1. Run `cd .\CLibSFPluginTemplate\`
1515
2. Run `py .\project_setup.py`
1616
3. Choose how to consume CommonLibSF
17-
1. Press `Enter` to use the default of consuming CommonLibSF via vcpkg
17+
1. Press `Enter` to use the default of consuming CommonLibSF via CPM
1818
2. Enter `y` to consume CommonLibSF as a git submodule instead
1919
4. To use a local fork of CommonLibSF instead of the vcpkg port or a git submodule:
2020
1. Create a Windows environment variable called `CommonLibSFPath` that points to your local fork of CommonLibSF
@@ -33,6 +33,8 @@ A python script, `project_setup.py`, is provided which automates several houseke
3333
- `Release`: Optimized release build, produces small and fast DLLs with associated PDBs
3434
- `Debug`: Debug build, produces DLLs and PDBs with full debug info, allowing the use of an interactive debugger
3535

36+
Variants of both of the above configs are provided which use MSVC (`cl/link`) and Clang (`clang-cl/lld-link`) respectively.
37+
3638
## Plugin configuration using an `.ini`
3739

3840
Many CommonLib plugins expose settings through configuration files so that the user can control plugin behavior. This template includes [simpleini](https://github.com/brofield/simpleini) which allows you to read settings from the ini file in `contrib\config` (see `Settings.cpp`).
@@ -44,8 +46,6 @@ This template uses CommonLibSF's GPLv3 with exceptions. Per the license, **you m
4446
## Dependencies
4547

4648
- [CMake v3.27+](https://cmake.org/)
47-
- [vcpkg v2023.08.09+](https://github.com/microsoft/vcpkg/releases)
48-
- Create a new Windows environment variable called `VCPKG_ROOT` which points to your vcpkg install directory
4949
- [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) with C++ workload
5050
- [Python](https://www.python.org/download)
51-
- [LLVM v17.0.0+](https://github.com/llvm/llvm-project/releases) (not really a dependency but nice to have)
51+
- [LLVM v17.0.0+](https://github.com/llvm/llvm-project/releases)

0 commit comments

Comments
 (0)