Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee committed Nov 2, 2023
1 parent 949c4d4 commit 6150514
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 91 deletions.
50 changes: 18 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
cmake_minimum_required(VERSION 3.27)

########################################################################################################################
## Define project
########################################################################################################################
project(
PluginName
VERSION 0.0.1
LANGUAGES CXX
)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
Expand All @@ -16,10 +14,11 @@ set(CMAKE_OPTIMIZE_DEPENDENCIES ON)

include(GNUInstallDirs)

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

set(CPM_SOURCE_CACHE ${CMAKE_CURRENT_BINARY_DIR}/.cpm)

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

Expand All @@ -31,30 +30,25 @@ configure_file(
@ONLY
)

set(PUBLIC_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME})

set(
# Add headers
file(
GLOB_RECURSE
headers
include/Utility.h
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp
)
list(REMOVE_ITEM headers ${CMAKE_CURRENT_SOURCE_DIR}/include/PCH.h)

set(
# Add sources
file(
GLOB_RECURSE
sources
src/Main.cpp
src/Settings.cpp
src/Hooks.cpp

${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc
${CMAKE_CURRENT_BINARY_DIR}/version.rc
)

source_group(
TREE ${CMAKE_CURRENT_SOURCE_DIR}
FILES ${headers} ${sources}
)

########################################################################################################################
## Configure target DLL
########################################################################################################################
# Create plugin
add_commonlibsf_plugin(
${PROJECT_NAME}
AUTHOR AuthorName
Expand All @@ -69,7 +63,7 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>
$<INSTALL_INTERFACE:src>
${SimpleIni_SOURCE_DIR}
$<BUILD_INTERFACE:${SimpleIni_SOURCE_DIR}>
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
Expand All @@ -81,19 +75,11 @@ target_precompile_headers(
${SimpleIni_SOURCE_DIR}/SimpleIni.h
)

install(
DIRECTORY ${PUBLIC_HEADER_DIR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(
TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

########################################################################################################################
## Automatic plugin deployment
########################################################################################################################
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(BUILD_NAME Debug)
else()
Expand All @@ -113,8 +99,8 @@ add_custom_command(
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Config/${PROJECT_NAME}.ini ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins
)

file(GLOB_RECURSE OUTPUT_DLLS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/**/*.dll)
file(GLOB_RECURSE OUTPUT_PDBS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/**/*.pdb)
file(GLOB_RECURSE OUTPUT_DLLS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/*.dll)
file(GLOB_RECURSE OUTPUT_PDBS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/*.pdb)

set_property(
TARGET ${PROJECT_NAME}
Expand Down
87 changes: 31 additions & 56 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,25 @@
{
"name": "base",
"hidden": true,
"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": "win32",
"hidden": true,
"environment": {
"COMMONLIBSF_PLATFORM": "-DWIN32_LEAN_AND_MEAN -DNOMINMAX"
}
},
{
"name": "x64",
"hidden": true,
"architecture": {
"value": "x64",
"strategy": "external"
}
"WINDOWS_FLAGS": "-DWIN32_LEAN_AND_MEAN -DNOMINMAX"
},
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/cgthreads8 /EHsc /fp:contract /fp:except- /W4 /Zc:__cplusplus $env{COMPILER_FLAGS} $env{WINDOWS_FLAGS} $penv{CXXFLAGS}",
"CMAKE_SHARED_LINKER_FLAGS": "$env{COMMONLIBSF_LINKER} $penv{SHARED_LINKER_FLAGS}"
},
"cmakeExecutable": "C:/Program Files/CMake/bin/",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}"
},
{
"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"
"COMPILER_FLAGS": "-fms-extensions -fdelayed-template-parsing -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": {
Expand All @@ -53,9 +41,8 @@
"name": "msvc",
"hidden": true,
"generator": "Ninja",
"cmakeExecutable": "C:/Program Files/CMake/bin/",
"environment": {
"COMMONLIBSF_COMPILER": "/cgthreads8 /diagnostics:caret /EHsc /fp:contract /fp:except- /guard:cf- /MP /permissive- /sdl /W4 /Zc:__cplusplus /Zc:enumTypes /Zc:lambda /Zc:preprocessor /Zc:referenceBinding /Zc:rvalueCast /Zc:templateScope /Zc:ternary",
"COMPILER_FLAGS": "/favor:blend /Zc:enumTypes /Zc:preprocessor /Zc:templateScope",
"COMMONLIBSF_LINKER": "/CGTHREADS:8 /MACHINE:x64 /DEBUG:FULL"
},
"vendor": {
Expand All @@ -67,72 +54,60 @@
},
{
"name": "build-release-clang-cl",
"inherits": ["base", "win32", "x64", "clang-cl"],
"inherits": ["base", "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"],
"inherits": ["base", "clang-cl"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"displayName": "Debug",
"description": "Debug build.",
"binaryDir": "${sourceDir}/build/debug-clang-cl"
}
},
{
"name": "build-release-msvc",
"inherits": ["base", "win32", "x64", "msvc"],
"inherits": ["base", "msvc"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/fp:fast /GR- /Gw /O2 /Ob3 /Qpar",
"CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO": "/LTCG:INCREMENTAL /OPT:ICF=4"
},
"displayName": "Release",
"description": "Optimized release build.",
"binaryDir": "${sourceDir}/build/release-msvc"
}
},
{
"name": "build-debug-msvc",
"inherits": ["base", "win32", "x64", "msvc"],
"inherits": ["base", "msvc"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_SHARED_LINKER_FLAGS_DEBUG": "/DEBUGTYPE:FIXUP"
},
"displayName": "Debug",
"description": "Debug build.",
"binaryDir": "${sourceDir}/build/debug-msvc"
}
}
],
"buildPresets": [
{
"name": "release-clang-cl",
"displayName": "1. Release (clang-cl)",
"configurePreset": "build-release-clang-cl",
"name": "release-msvc",
"displayName": "1. Release (MSVC)",
"configurePreset": "build-release-msvc",
"description": "Optimized release build."
},
{
"name": "debug-clang-cl",
"displayName": "2. Debug (clang-cl)",
"configurePreset": "build-debug-clang-cl",
"name": "debug-msvc",
"displayName": "2. Debug (MSVC)",
"configurePreset": "build-debug-msvc",
"description": "Debug build."
},
{
"name": "release-msvc",
"displayName": "3. Release (MSVC)",
"configurePreset": "build-release-msvc",
"name": "release-clang-cl",
"displayName": "3. Release (clang-cl)",
"configurePreset": "build-release-clang-cl",
"description": "Optimized release build."
},
{
"name": "debug-msvc",
"displayName": "4. Debug (MSVC)",
"configurePreset": "build-debug-msvc",
"name": "debug-clang-cl",
"displayName": "4. Debug (clang-cl)",
"configurePreset": "build-debug-clang-cl",
"description": "Debug build."
}
]
Expand Down
1 change: 1 addition & 0 deletions include/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class Singleton
public:
constexpr Singleton(const Singleton&) = delete;
constexpr Singleton(Singleton&&) = delete;

constexpr auto operator=(const Singleton&) = delete;
constexpr auto operator=(Singleton&&) = delete;

Expand Down
12 changes: 9 additions & 3 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
// SFSE message listener, use this to do stuff at specific moments during runtime
void Listener(SFSE::MessagingInterface::Message* message) noexcept
{
if (message->type <=> SFSE::MessagingInterface::kPostLoad == 0) {
switch (message->type) {
case SFSE::MessagingInterface::kPostLoad: {
}
if (message->type <=> SFSE::MessagingInterface::kPostPostLoad == 0) {
case SFSE::MessagingInterface::kPostPostLoad: {
}
case SFSE::MessagingInterface::kPostDataLoad: {
Settings::LoadSettings();
Hooks::Install();
}
if (message->type <=> SFSE::MessagingInterface::kPostDataLoad == 0) {
case SFSE::MessagingInterface::kPostPostDataLoad: {
}
default: {
}
}
}

Expand Down

0 comments on commit 6150514

Please sign in to comment.