-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
147 lines (127 loc) · 8.07 KB
/
CMakeLists.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
cmake_minimum_required(VERSION 3.28)
# DevTools
project(devtools VERSION 0.1.64
DESCRIPTION "Hedgehog Engine 2 DevTools"
LANGUAGES CXX)
set(PROJECT_AUTHOR "angryzor")
set(PROJECT_COPYRIGHT "Copyright (c) 2024 angryzor - Licensed under GPL3")
set(PROJECT_DOWNLOAD_SIZE "2.42 MB")
string(TIMESTAMP PROJECT_BUILD_DATE "%Y-%m-%d")
option(DEVTOOLS_ENABLE_IMGUI_DEMO_WINDOW "Enable ImGui demo window" OFF)
option(DEVTOOLS_ENABLE_IMPLOT_DEMO_WINDOW "Enable ImPlot demo window" OFF)
option(DEVTOOLS_INSTALL_TO_UPDATE_SERVER "Install to update server" OFF)
set(DEVTOOLS_UPDATE_SERVER_PATH "" CACHE PATH "Path to update server")
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>")
set(OGDF_DEBUG_MODE NONE)
include(FetchContent)
FetchContent_Declare(OGDF GIT_REPOSITORY https://github.com/ogdf/ogdf.git GIT_TAG 7d2a71816f2c12ad858ecc805cbe421b45935c42 EXCLUDE_FROM_ALL FIND_PACKAGE_ARGS)
FetchContent_Declare(rip GIT_REPOSITORY https://github.com/angryzor/rip.git GIT_TAG v1.0.19 EXCLUDE_FROM_ALL FIND_PACKAGE_ARGS 1.0.19)
FetchContent_MakeAvailable(ogdf rip)
add_subdirectory(vendor EXCLUDE_FROM_ALL)
# Settings for target sdks
set(SDK_VAR_wars "SONIC_FORCES_SDK")
set(GAME_FOLDER_DEFAULT_wars "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SonicForces")
set(GAME_EXECUTABLE_wars "build/main/projects/exec/Sonic Forces.exe")
set(DEBUGGER_WORKING_DIRECTORY_wars "build/main/projects/exec")
set(MODS_SUBFOLDER_wars "build/main/projects/exec/Mods")
set(UPDATE_SERVER_NAMESPACE_wars "sonic-forces")
set(FRIENDLY_GAME_NAME_wars "Sonic Forces")
set(SDK_VAR_rangers "SONIC_FRONTIERS_SDK")
set(GAME_FOLDER_DEFAULT_rangers "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SonicFrontiers")
set(GAME_EXECUTABLE_rangers "SonicFrontiers.exe")
set(DEBUGGER_WORKING_DIRECTORY_rangers "")
set(MODS_SUBFOLDER_rangers "Mods")
set(UPDATE_SERVER_NAMESPACE_rangers "sonic-frontiers")
set(FRIENDLY_GAME_NAME_rangers "Sonic Frontiers")
set(SDK_VAR_miller "MILLER_SDK")
set(GAME_FOLDER_DEFAULT_miller "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SONIC_X_SHADOW_GENERATIONS")
set(GAME_EXECUTABLE_miller "SONIC_X_SHADOW_GENERATIONS.exe")
set(DEBUGGER_WORKING_DIRECTORY_miller "")
set(MODS_SUBFOLDER_miller "mods_shadow")
set(UPDATE_SERVER_NAMESPACE_miller "shadow-generations")
set(FRIENDLY_GAME_NAME_miller "Shadow Generations")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/archives")
if(DEVTOOLS_INSTALL_TO_UPDATE_SERVER)
cmake_path(SET UPDATE_SERVER_PATH_NORMALIZED NORMALIZE ${DEVTOOLS_UPDATE_SERVER_PATH})
endif()
# The main target
foreach(DEVTOOLS_TARGET_SDK miller rangers wars)
set(PROJECT_DESCRIPTION "${FRIENDLY_GAME_NAME_${DEVTOOLS_TARGET_SDK}} DevTools")
set(PROJECT_LONG_DESCRIPTION "In-engine development kit for ${FRIENDLY_GAME_NAME_${DEVTOOLS_TARGET_SDK}}")
set(GAME_FOLDER_${DEVTOOLS_TARGET_SDK} ${GAME_FOLDER_DEFAULT_${DEVTOOLS_TARGET_SDK}} CACHE STRING "The location of your ${DEVTOOLS_TARGET_SDK} game folder.")
set(DEVTOOLS_TARGET devtools-${DEVTOOLS_TARGET_SDK})
set(UPDATE_SERVER_NAMESPACE ${UPDATE_SERVER_NAMESPACE_${DEVTOOLS_TARGET_SDK}})
message("Using game folder ${GAME_FOLDER_${DEVTOOLS_TARGET_SDK}} for target SDK ${DEVTOOLS_TARGET_SDK}.")
cmake_path(SET GAME_FOLDER_NORMALIZED NORMALIZE ${GAME_FOLDER_${DEVTOOLS_TARGET_SDK}})
cmake_path(APPEND GAME_FOLDER_NORMALIZED ${GAME_EXECUTABLE_${DEVTOOLS_TARGET_SDK}} OUTPUT_VARIABLE GAME_EXECUTABLE)
cmake_path(APPEND GAME_FOLDER_NORMALIZED ${DEBUGGER_WORKING_DIRECTORY_${DEVTOOLS_TARGET_SDK}} OUTPUT_VARIABLE DEBUGGER_WORKING_DIRECTORY)
cmake_path(APPEND GAME_FOLDER_NORMALIZED ${MODS_SUBFOLDER_${DEVTOOLS_TARGET_SDK}} OUTPUT_VARIABLE MODS_FOLDER)
cmake_path(APPEND MODS_FOLDER "devtools" OUTPUT_VARIABLE MOD_FOLDER)
string(TOUPPER ${DEVTOOLS_TARGET_SDK} DEVTOOLS_TARGET_SDK_UPPERCASE)
set(${DEVTOOLS_TARGET_SDK_UPPERCASE}_SDK_CUSTOM_EIGEN_TARGET eigen)
if(DEFINED ENV{${SDK_VAR_${DEVTOOLS_TARGET_SDK}}})
message("${SDK_VAR_${DEVTOOLS_TARGET_SDK}} environment variable found. Using this version instead of the local submodule.")
cmake_path(SET SDK_PATH NORMALIZE $ENV{${SDK_VAR_${DEVTOOLS_TARGET_SDK}}})
else()
set(SDK_PATH sdks/${DEVTOOLS_TARGET_SDK}-sdk)
endif()
add_subdirectory(${SDK_PATH} ${DEVTOOLS_TARGET_SDK}-sdk EXCLUDE_FROM_ALL)
add_library(${DEVTOOLS_TARGET} SHARED)
target_link_libraries(${DEVTOOLS_TARGET} PRIVATE ${DEVTOOLS_TARGET_SDK}-sdk filewatch detours imgui imgui-backend-win32 imgui-backend-dx11 imgui-file-dialog imgui-node-editor imgui-memory-editor imguizmo implot imtimeline reflectcpp OGDF rip-hl)
target_compile_features(${DEVTOOLS_TARGET} PRIVATE cxx_std_20)
target_compile_options(${DEVTOOLS_TARGET} PRIVATE /permissive- /W4 /wd4100 /wd4458 /wd4324)
target_compile_definitions(${DEVTOOLS_TARGET}
PRIVATE
DEVTOOLS_BINARY_FILENAME=$<TARGET_FILE_NAME:${DEVTOOLS_TARGET}>
DEVTOOLS_TARGET_SDK="${DEVTOOLS_TARGET_SDK}"
DEVTOOLS_TARGET_SDK_${DEVTOOLS_TARGET_SDK}=1
DEVTOOLS_PROJECT_AUTHOR="${PROJECT_AUTHOR}"
DEVTOOLS_PROJECT_DESCRIPTION="${PROJECT_DESCRIPTION}"
DEVTOOLS_PROJECT_LONG_DESCRIPTION="${PROJECT_LONG_DESCRIPTION}"
DEVTOOLS_PROJECT_COPYRIGHT="${PROJECT_COPYRIGHT}"
DEVTOOLS_BUILD_DATE="${PROJECT_BUILD_DATE}"
DEVTOOLS_VERSION=${PROJECT_VERSION}
DEVTOOLS_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
DEVTOOLS_VERSION_MINOR=${PROJECT_VERSION_MINOR}
DEVTOOLS_VERSION_PATCH=${PROJECT_VERSION_PATCH}
)
set_target_properties(${DEVTOOLS_TARGET}
PROPERTIES
VS_DEBUGGER_COMMAND ${GAME_EXECUTABLE}
VS_DEBUGGER_WORKING_DIRECTORY ${DEBUGGER_WORKING_DIRECTORY}
)
if(DEVTOOLS_ENABLE_IMGUI_DEMO_WINDOW)
target_compile_definitions(${DEVTOOLS_TARGET} PRIVATE DEVTOOLS_ENABLE_IMGUI_DEMO_WINDOW=1)
endif()
if(DEVTOOLS_ENABLE_IMPLOT_DEMO_WINDOW)
target_compile_definitions(${DEVTOOLS_TARGET} PRIVATE DEVTOOLS_ENABLE_IMPLOT_DEMO_WINDOW=1)
endif()
add_subdirectory(src ${DEVTOOLS_TARGET}/src)
add_subdirectory(natvis ${DEVTOOLS_TARGET}/natvis)
configure_file(mod.ini.in ${DEVTOOLS_TARGET}/mod.ini)
configure_file(mod_version.ini.in ${DEVTOOLS_TARGET}/mod_version.ini)
install(TARGETS ${DEVTOOLS_TARGET} RUNTIME DESTINATION "${MOD_FOLDER}")
install(DIRECTORY resources/common/ DESTINATION "${MOD_FOLDER}")
install(DIRECTORY resources/${DEVTOOLS_TARGET_SDK}/ DESTINATION "${MOD_FOLDER}")
install(FILES LICENSE.txt CHANGELOG.md "${CMAKE_CURRENT_BINARY_DIR}/${DEVTOOLS_TARGET}/mod.ini" DESTINATION "${MOD_FOLDER}")
install(CODE "
execute_process(
COMMAND \$\{CMAKE_COMMAND} \"-E\" \"tar\" \"cvf\" \"${CMAKE_CURRENT_BINARY_DIR}/archives/devtools-${DEVTOOLS_TARGET_SDK}-v${PROJECT_VERSION}.zip\" \"--format=zip\" \"devtools\"
WORKING_DIRECTORY \"${MODS_FOLDER}\"
)
")
if(DEFINED UPDATE_SERVER_PATH_NORMALIZED)
cmake_path(APPEND UPDATE_SERVER_PATH_NORMALIZED "${UPDATE_SERVER_NAMESPACE}/devtools" OUTPUT_VARIABLE UPDATE_SERVER_MOD_FOLDER)
install(TARGETS ${DEVTOOLS_TARGET} RUNTIME DESTINATION ${UPDATE_SERVER_MOD_FOLDER})
install(DIRECTORY resources/common/ DESTINATION ${UPDATE_SERVER_MOD_FOLDER})
install(DIRECTORY resources/${DEVTOOLS_TARGET_SDK}/ DESTINATION ${UPDATE_SERVER_MOD_FOLDER})
install(FILES LICENSE.txt CHANGELOG.md "${CMAKE_CURRENT_BINARY_DIR}/${DEVTOOLS_TARGET}/mod.ini" "${CMAKE_CURRENT_BINARY_DIR}/${DEVTOOLS_TARGET}/mod_version.ini" DESTINATION ${UPDATE_SERVER_MOD_FOLDER})
install(CODE "
file(GLOB_RECURSE UPDATE_SERVER_FILES LIST_DIRECTORIES false RELATIVE \"${UPDATE_SERVER_MOD_FOLDER}\" \"${UPDATE_SERVER_MOD_FOLDER}/*\")
list(REMOVE_ITEM UPDATE_SERVER_FILES \"mod_files.txt\" \"mod_version.ini\")
list(TRANSFORM UPDATE_SERVER_FILES PREPEND \"add \")
list(JOIN UPDATE_SERVER_FILES \"\\n\" UPDATE_SERVER_MOD_FILES_CONTENT)
file(WRITE \"${UPDATE_SERVER_MOD_FOLDER}/mod_files.txt\" \"\${UPDATE_SERVER_MOD_FILES_CONTENT}\\n\")
")
endif()
endforeach()