-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
62 lines (50 loc) · 2.31 KB
/
CMakeLists.txt
File metadata and controls
62 lines (50 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Set the minimum required CMake version.
cmake_minimum_required(VERSION 3.16)
# Define our project.
project(SPF VERSION 1.0.0 LANGUAGES CXX)
# Set C++20 standard for the entire project.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Define the name of our plugin
set(PLUGIN_NAME SPF_ConsoleCommandHotkeys)
# Create the plugin as a shared library (DLL)
add_library(${PLUGIN_NAME} SHARED
"SPF_ConsoleCommandHotkeys.cpp"
)
target_include_directories(${PLUGIN_NAME} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/SPF_API"
)
set(GAME_PLUGINS_DIR "E:/SteamLibrary/steamapps/common/American Truck Simulator/bin/win_x64/plugins" CACHE PATH "Path to the game's plugins directory")
# All plugins should go into a 'plugins' subfolder in the output directory
set_target_properties(${PLUGIN_NAME} PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/${PLUGIN_NAME}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/${PLUGIN_NAME}"
)
# --- Deployment ---
# This section is optional but convenient. It copies the final DLL
# to the game's actual plugin directory with the correct structure.
if(EXISTS "${GAME_PLUGINS_DIR}")
# Define the final deployment directory for this specific plugin
set(PLUGIN_DEPLOY_DIR "${GAME_PLUGINS_DIR}/spfPlugins/${PLUGIN_NAME}")
# This command ensures the destination directory exists before we try to copy the file.
add_custom_command(TARGET ${PLUGIN_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${PLUGIN_DEPLOY_DIR}"
COMMENT "Ensuring deployment directory exists for ${PLUGIN_NAME}"
)
# This command copies the compiled DLL to the correct final location.
add_custom_command(TARGET ${PLUGIN_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:${PLUGIN_NAME}>"
"${PLUGIN_DEPLOY_DIR}"
COMMENT "Deploying ${PLUGIN_NAME}.dll to ${PLUGIN_DEPLOY_DIR}"
)
# This command copies the localization files to the deployment directory.
add_custom_command(TARGET ${PLUGIN_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/localization"
"${PLUGIN_DEPLOY_DIR}/localization"
COMMENT "Deploying localization files for ${PLUGIN_NAME}"
)
endif()