Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee committed Oct 24, 2023
1 parent b3541af commit 19dfe89
Show file tree
Hide file tree
Showing 7 changed files with 1,242 additions and 108 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/testbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
types: completed
workflow_dispatch:

env:
VCPKG_COMMIT_ID: e44d60e6bf0964064bf69667cd9f3e91dc383c7c

jobs:
test-build:
runs-on: windows-latest
Expand All @@ -18,20 +15,23 @@ jobs:
preset:
- debug
- release
compiler:
- msvc
- clang-cl
steps:
- name: Checkout
uses: actions/checkout@v4

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

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

- name: Run CMake
uses: lukka/[email protected]
with:
configurePreset: build-${{ matrix.preset }}-msvc
buildPreset: ${{ matrix.preset }}-msvc
- name: Build
run: |
cmake -B ./build --preset=build-${{ matrix.preset }}-${{ matrix.compiler }}
cmake --build ./build --preset=${{ matrix.preset }}-${{ matrix.compiler }}
20 changes: 13 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.27)
message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.")

########################################################################################################################
## Define project
Expand All @@ -17,6 +16,13 @@ set(CMAKE_OPTIMIZE_DEPENDENCIES ON)

include(GNUInstallDirs)

include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")

CPMAddPackage("gh:Starfield-Reverse-Engineering/CommonLibSF#main")
CPMAddPackage("gh:brofield/[email protected]")

include("${CommonLibSF_SOURCE_DIR}/CommonLibSF/cmake/CommonLibSF.cmake")

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in
${CMAKE_CURRENT_BINARY_DIR}/version.rc
Expand Down Expand Up @@ -47,8 +53,6 @@ source_group(
########################################################################################################################
## Configure target DLL
########################################################################################################################
find_package(CommonLibSF CONFIG REQUIRED)

add_commonlibsf_plugin(
${PROJECT_NAME}
AUTHOR AuthorName
Expand All @@ -57,15 +61,13 @@ add_commonlibsf_plugin(

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

find_path(SIMPLEINI_INCLUDE_DIRS "SimpleIni.h")

target_include_directories(
${PROJECT_NAME}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>
$<INSTALL_INTERFACE:src>
${SIMPLEINI_INCLUDE_DIRS}
${SimpleIni_SOURCE_DIR}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
Expand All @@ -74,7 +76,7 @@ target_precompile_headers(
${PROJECT_NAME}
PRIVATE
include/PCH.h
${SIMPLEINI_INCLUDE_DIRS}/SimpleIni.h
${SimpleIni_SOURCE_DIR}/SimpleIni.h
)

install(
Expand Down Expand Up @@ -132,3 +134,7 @@ set_property(
TARGET ${PROJECT_NAME}
APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${OUTPUT_PDBS}"
)
set_property(
TARGET ${PROJECT_NAME}
APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/build/.cpm"
)
72 changes: 58 additions & 14 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,8 @@
"cacheVariables": {
"CMAKE_CXX_FLAGS": "$env{COMMONLIBSF_COMPILER} $env{COMMONLIBSF_PLATFORM} $penv{CXXFLAGS}",
"CMAKE_SHARED_LINKER_FLAGS": "$env{COMMONLIBSF_LINKER} $penv{SHARED_LINKER_FLAGS}",
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
}
},
{
"name": "vcpkg",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md",
"VCPKG_HOST_TRIPLET": "x64-windows-static-md"
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
"CPM_SOURCE_CACHE": "${sourceDir}/build/.cpm"
}
},
{
Expand All @@ -39,6 +31,25 @@
"strategy": "external"
}
},
{
"name": "clang-cl",
"hidden": true,
"generator": "Ninja",
"cmakeExecutable": "C:/Program Files/CMake/bin/",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang-cl"
},
"environment": {
"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"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"intelliSenseMode": "windows-clang-x64",
"enableMicrosoftCodeAnalysis": true,
"enableClangTidyCodeAnalysis": true
}
}
},
{
"name": "msvc",
"hidden": true,
Expand All @@ -55,9 +66,30 @@
}
}
},
{
"name": "build-release-clang-cl",
"inherits": [ "base", "win32", "x64", "clang-cl" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/fp:fast /GR- /Gw /O2"
},
"displayName": "Release",
"description": "Optimized release build.",
"binaryDir": "${sourceDir}/build/release-clang-cl"
},
{
"name": "build-debug-clang-cl",
"inherits": [ "base", "win32", "x64", "clang-cl" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"displayName": "Debug",
"description": "Debug build.",
"binaryDir": "${sourceDir}/build/debug-clang-cl"
},
{
"name": "build-release-msvc",
"inherits": ["base", "vcpkg", "win32", "x64", "msvc"],
"inherits": [ "base", "win32", "x64", "msvc" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/fp:fast /GR- /Gw /O2 /Ob3 /Qpar",
Expand All @@ -69,7 +101,7 @@
},
{
"name": "build-debug-msvc",
"inherits": ["base", "vcpkg", "win32", "x64", "msvc"],
"inherits": [ "base", "win32", "x64", "msvc" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_SHARED_LINKER_FLAGS_DEBUG": "/DEBUGTYPE:FIXUP"
Expand All @@ -80,15 +112,27 @@
}
],
"buildPresets": [
{
"name": "release-clang-cl",
"displayName": "1. Release (clang-cl)",
"configurePreset": "build-release-clang-cl",
"description": "Optimized release build."
},
{
"name": "debug-clang-cl",
"displayName": "2. Debug (clang-cl)",
"configurePreset": "build-debug-clang-cl",
"description": "Debug build."
},
{
"name": "release-msvc",
"displayName": "1. Release (MSVC)",
"displayName": "3. Release (MSVC)",
"configurePreset": "build-release-msvc",
"description": "Optimized release build."
},
{
"name": "debug-msvc",
"displayName": "2. Debug (MSVC)",
"displayName": "4. Debug (MSVC)",
"configurePreset": "build-debug-msvc",
"description": "Debug build."
}
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

## Setup

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).
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).

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:

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

Variants of both of the above configs are provided which use MSVC (`cl/link`) and Clang (`clang-cl/lld-link`) respectively.

## Plugin configuration using an `.ini`

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`).
Expand All @@ -44,8 +46,6 @@ This template uses CommonLibSF's GPLv3 with exceptions. Per the license, **you m
## Dependencies

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

0 comments on commit 19dfe89

Please sign in to comment.