Skip to content

Commit cce0ed6

Browse files
authored
Merge pull request #996 from UE4SS-RE/CMake2001ASpaceOdyssey
2 parents f66507e + 622bed8 commit cce0ed6

File tree

92 files changed

+11706
-708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+11706
-708
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,11 @@ _ReSharper*/
7171
.cache
7272
.xwin-cache
7373

74+
.clangd
75+
compile_commands.json
76+
7477
# xmake generated projects
7578
vsxmake2022
79+
80+
# xwin
81+
xwin/*

CMakeLists.txt

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
3+
project(UE4SSMonorepo)
4+
5+
# Basic setup
6+
set(CMAKE_CXX_STANDARD 23)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
set(CMAKE_CXX_EXTENSIONS OFF)
9+
10+
enable_language(CXX ASM_MASM)
11+
include(CheckIPOSupported)
12+
include(GNUInstallDirs)
13+
14+
# CMake Module Path
15+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
16+
17+
# Include helper modules
18+
include(IDEOrganization) # For organizing targets in the IDE
19+
include(Utilities) # For utility functions
20+
include(IDEVisibility) # For IDE visibility of source files
21+
include(ThirdPartyWarnings) # For suppressing warnings from third-party libraries
22+
include(CompilerDetection) # For compiler detection and reporting
23+
include(ProjectConfig) # For centralized project configuration
24+
include(VersionChecks) # For compiler and tool version checking
25+
include(ArchitectureDetection) # For CPU architecture and feature detection
26+
27+
# Check IPO/LTO support
28+
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
29+
message("IPO/LTO support: ${IPO_SUPPORTED}; ${IPO_ERROR}")
30+
31+
# Initialize project configuration
32+
# Uses ue4ss_initialize_project() from cmake/modules/ProjectConfig.cmake
33+
ue4ss_initialize_project()
34+
35+
# Projects list is now in ProjectConfig.cmake
36+
set(PROJECTS ${UE4SS_PROJECTS})
37+
38+
# Fix for ninja/clang
39+
unset(CMAKE_CXX_SIMULATE_ID)
40+
41+
# Detailed compiler detection output
42+
# Detect and print compiler information
43+
# Uses detect_and_print_compiler() from cmake/modules/CompilerDetection.cmake
44+
detect_and_print_compiler()
45+
46+
# Perform version checks
47+
# Uses perform_version_checks() from cmake/modules/VersionChecks.cmake
48+
perform_version_checks()
49+
50+
# Global compile definitions are now set by ue4ss_initialize_project()
51+
52+
# Set default output directories
53+
# These create the structure: [BuildDir]/Game__Shipping__Win64/bin/
54+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>/${CMAKE_INSTALL_BINDIR})
55+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>/${CMAKE_INSTALL_LIBDIR})
56+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>/${CMAKE_INSTALL_LIBDIR})
57+
58+
# Initialize compiler options
59+
add_subdirectory("cmake/modules/CompilerOptions")
60+
61+
# Set compiler options
62+
add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:ASM_MASM>>:${DEFAULT_COMPILER_FLAGS}>")
63+
add_link_options("${DEFAULT_SHARED_LINKER_FLAGS}" "${DEFAULT_EXE_LINKER_FLAGS}")
64+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
65+
66+
# Compiler flags are now initialized by ue4ss_initialize_project()
67+
list(APPEND Game_FLAGS "")
68+
list(APPEND CasePreserving_FLAGS ${Game_FLAGS})
69+
list(APPEND LessEqual421_FLAGS ${Game_FLAGS})
70+
71+
# Build configurations are now defined in ProjectConfig.cmake
72+
# Generate build configurations
73+
# Uses generate_build_configurations() from cmake/modules/Utilities.cmake
74+
generate_build_configurations()
75+
76+
# Set default configuration
77+
# Uses setup_build_configuration() from cmake/modules/Utilities.cmake
78+
setup_build_configuration()
79+
80+
# Add subdirectories for dependencies and projects
81+
add_subdirectory("deps")
82+
add_subdirectory("cppmods")
83+
84+
foreach(project ${PROJECTS})
85+
add_subdirectory(${project})
86+
endforeach()
87+
88+
# Organize all targets using the master function
89+
# Uses organize_all_targets() from cmake/modules/IDEOrganization.cmake
90+
organize_all_targets()
91+
92+
# Explicitly place UE4SS at the root under RE-UE4SS
93+
if(TARGET UE4SS)
94+
set_target_properties(UE4SS PROPERTIES FOLDER "RE-UE4SS")
95+
endif()
96+
97+
# Apply compiler settings to all targets
98+
# Uses apply_compiler_settings_to_targets() from cmake/modules/IDEOrganization.cmake
99+
apply_compiler_settings_to_targets("${TARGET_COMPILE_OPTIONS}" "${TARGET_LINK_OPTIONS}" "${TARGET_COMPILE_DEFINITIONS}")

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ Currently supported options for these are:
103103
> [!TIP]
104104
> Configure the project using this command: `xmake f -m "<BuildMode>"`. `-m` is an alias for --**m**ode=\<BuildMode>.
105105
106-
#### Patternsleuth (Experimental)
107-
108-
By default, the patternsleuth tool installs itself as an xmake package. If you do not intend on modifying the patternsleuth source code, then you don't have to configure anything special. If you want to be able to modify the patternsleuth source code, you have to supply the `--patternsleuth=local` option to `xmake config` in order to recompile patternsleuth as part of the UE4SS build.
109-
110106
#### Proxy Path
111107

112108
By default, UE4SS generates a proxy based on `C:\Windows\System32\dwmapi.dll`. If you want to change this for any reason, you can supply the `--ue4ssProxyPath=<path proxy dll>` to the `xmake config` command..

UE4SS/CMakeLists.txt

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
project(UE4SS)
3+
4+
message("Configuring UE4SS")
5+
6+
# Add proxy generator subproject
7+
add_subdirectory("proxy_generator")
8+
9+
# Release settings
10+
option(UE4SS_LIB_BETA_IS_STARTED "Have beta releases started for the current major version" ON)
11+
option(UE4SS_LIB_IS_BETA "Is this a beta release" ON)
12+
13+
# Define generated directories
14+
set(UE4SS_GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated_include")
15+
set(UE4SS_GENERATED_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated_src")
16+
17+
# ---------------------------------------------------------------------------
18+
# Version Information
19+
# ---------------------------------------------------------------------------
20+
21+
# Read version from file
22+
file(READ ${UE4SS_GENERATED_SOURCE_DIR}/version.cache UE4SS_LIB_VERSION)
23+
string(REGEX MATCHALL "([0-9]+).([0-9]+).([0-9]+).([0-9]+).([0-9]+)" VERSION_PARTS "${UE4SS_LIB_VERSION}")
24+
set(UE4SS_LIB_VERSION_MAJOR ${CMAKE_MATCH_1})
25+
set(UE4SS_LIB_VERSION_MINOR ${CMAKE_MATCH_2})
26+
set(UE4SS_LIB_VERSION_HOTFIX ${CMAKE_MATCH_3})
27+
set(UE4SS_LIB_VERSION_PRERELEASE ${CMAKE_MATCH_4}) # Publicly available pre-release
28+
set(UE4SS_LIB_VERSION_BETA ${CMAKE_MATCH_5}) # Pre-pre-release version
29+
30+
# Get Git SHA
31+
find_package(Git QUIET)
32+
if(GIT_FOUND)
33+
execute_process(
34+
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
35+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
36+
RESULT_VARIABLE GIT_RESULT
37+
OUTPUT_VARIABLE UE4SS_LIB_BUILD_GITSHA
38+
OUTPUT_STRIP_TRAILING_WHITESPACE
39+
ERROR_QUIET
40+
)
41+
if(NOT GIT_RESULT EQUAL 0)
42+
set(UE4SS_LIB_BUILD_GITSHA "unknown")
43+
endif()
44+
else()
45+
set(UE4SS_LIB_BUILD_GITSHA "no-git")
46+
endif()
47+
48+
# Add version definitions
49+
add_compile_definitions(
50+
UE4SS_LIB_VERSION_MAJOR=${UE4SS_LIB_VERSION_MAJOR}
51+
UE4SS_LIB_VERSION_MINOR=${UE4SS_LIB_VERSION_MINOR}
52+
UE4SS_LIB_VERSION_HOTFIX=${UE4SS_LIB_VERSION_HOTFIX}
53+
UE4SS_LIB_VERSION_PRERELEASE=${UE4SS_LIB_VERSION_PRERELEASE}
54+
UE4SS_LIB_VERSION_BETA=${UE4SS_LIB_VERSION_BETA}
55+
UE4SS_LIB_BETA_STARTED=$<BOOL:${UE4SS_LIB_BETA_IS_STARTED}>
56+
UE4SS_LIB_IS_BETA=$<BOOL:${UE4SS_LIB_IS_BETA}>
57+
UE4SS_LIB_BUILD_GITSHA="${UE4SS_LIB_BUILD_GITSHA}"
58+
UE4SS_CONFIGURATION="$<CONFIG>"
59+
)
60+
61+
message("UE4SS Version: ${UE4SS_LIB_VERSION_MAJOR}.${UE4SS_LIB_VERSION_MINOR}.${UE4SS_LIB_VERSION_HOTFIX}.${UE4SS_LIB_VERSION_PRERELEASE}.${UE4SS_LIB_VERSION_BETA} (${UE4SS_LIB_BUILD_GITSHA})")
62+
63+
# ---------------------------------------------------------------------------
64+
# Target Configuration
65+
# ---------------------------------------------------------------------------
66+
67+
# Find source files
68+
file(GLOB_RECURSE UE4SS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/**.cpp")
69+
file(GLOB_RECURSE UE4SS_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/**.hpp")
70+
71+
# Create the main library
72+
add_library(UE4SS SHARED ${UE4SS_SOURCES})
73+
74+
# Set C++23 standard
75+
target_compile_features(UE4SS PUBLIC cxx_std_23)
76+
77+
# Add include directories
78+
target_include_directories(UE4SS PUBLIC
79+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
80+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/generated_include>
81+
)
82+
83+
# Add headers as sources for IDE integration
84+
target_sources(UE4SS PUBLIC
85+
FILE_SET ue4ss_headers TYPE HEADERS
86+
BASE_DIRS include
87+
FILES ${UE4SS_HEADERS}
88+
)
89+
90+
# Organize in IDE
91+
source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${UE4SS_SOURCES} ${UE4SS_HEADERS})
92+
93+
# First party static build definitions
94+
target_compile_definitions(UE4SS PRIVATE
95+
RC_UE4SS_EXPORTS
96+
RC_ASM_HELPER_BUILD_STATIC
97+
RC_FILE_BUILD_STATIC
98+
RC_DYNAMIC_OUTPUT_BUILD_STATIC
99+
RC_SINGLE_PASS_SIG_SCANNER_BUILD_STATIC
100+
RC_SINGLE_PASS_SIG_SCANNER_STATIC
101+
RC_UNREAL_BUILD_STATIC
102+
RC_INPUT_BUILD_STATIC
103+
RC_LUA_MADE_SIMPLE_BUILD_STATIC
104+
RC_FUNCTION_TIMER_BUILD_STATIC
105+
RC_PARSER_BASE_BUILD_STATIC
106+
RC_INI_PARSER_BUILD_STATIC
107+
RC_JSON_BUILD_STATIC
108+
RC_JSON_PARSER_BUILD_STATIC
109+
RC_LUA_WRAPPER_GENERATOR_BUILD_STATIC
110+
)
111+
112+
# ---------------------------------------------------------------------------
113+
# Dependencies
114+
# ---------------------------------------------------------------------------
115+
116+
# Link first-party dependencies
117+
target_link_libraries(UE4SS PUBLIC
118+
File glaze::glaze DynamicOutput
119+
Unreal SinglePassSigScanner LuaMadeSimple
120+
Function IniParser JSON
121+
Input Constructs Helpers
122+
MProgram ScopedTimer Profiler
123+
patternsleuth_bind
124+
)
125+
126+
# Link third-party dependencies
127+
target_link_libraries(UE4SS PUBLIC
128+
fmt ImGui PolyHook_2
129+
d3d11 glfw glad opengl32
130+
dbghelp psapi ws2_32 ntdll userenv
131+
)
132+
133+
# ---------------------------------------------------------------------------
134+
# Output Configuration
135+
# ---------------------------------------------------------------------------
136+
137+
# Enable link-time optimization
138+
set_property(TARGET UE4SS PROPERTY INTERPROCEDURAL_OPTIMIZATION ON)
139+
140+
# Set runtime library to DLL for C++ mods compatibility
141+
set_property(TARGET UE4SS PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
142+
143+
# Set output name and standard
144+
set_target_properties(UE4SS PROPERTIES
145+
OUTPUT_NAME "UE4SS"
146+
CXX_STANDARD 23
147+
)
148+
149+
# Use the organize_targets function from IDEOrganization.cmake
150+
# The organize_special_targets function will also handle this target
151+
organize_targets("^UE4SS$" "RE-UE4SS")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
3+
set(TARGET proxy_generator)
4+
project(${TARGET})
5+
6+
add_executable(${TARGET} "main.cpp")
7+
target_link_libraries(${TARGET} PRIVATE Constructs File imagehlp)
8+
target_compile_definitions(${TARGET} PRIVATE RC_FILE_BUILD_STATIC)
9+
10+
# Directly set folder for proxy_generator to Programs/proxy
11+
set_target_properties(${TARGET} PROPERTIES FOLDER "Programs/proxy")
12+
13+
add_subdirectory("proxy")

0 commit comments

Comments
 (0)