Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/xenon-emu/xenon
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsh1ft3r committed Mar 5, 2025
2 parents 7ae567b + 705f51d commit 62570a4
Show file tree
Hide file tree
Showing 8 changed files with 321 additions and 123 deletions.
44 changes: 27 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ project(Xenon)
# This function should be passed a list of all files in a target. It will automatically generate file groups
# following the directory hierarchy, so that the layout of the files in IDEs matches the one in the filesystem.
function(create_target_directory_groups target_name)
# Place any files that aren't in the source list in a separate group so that they don't get in the way.
source_group("Other Files" REGULAR_EXPRESSION ".")
get_target_property(target_sources "${target_name}" SOURCES)
foreach(file_name IN LISTS target_sources)
get_filename_component(dir_name "${file_name}" PATH)
# Group names use '\' as a separator even though the entire rest of CMake uses '/'...
string(REPLACE "/" "\\" group_name "${dir_name}")
source_group("${group_name}" FILES "${file_name}")
endforeach()
# Place any files that aren't in the source list in a separate group so that they don't get in the way.
source_group("Other Files" REGULAR_EXPRESSION ".")
get_target_property(target_sources "${target_name}" SOURCES)
foreach(file_name IN LISTS target_sources)
get_filename_component(dir_name "${file_name}" PATH)
# Group names use '\' as a separator even though the entire rest of CMake uses '/'...
string(REPLACE "/" "\\" group_name "${dir_name}")
source_group("${group_name}" FILES "${file_name}")
endforeach()
endfunction()

find_package(fmt 10.2.1 CONFIG)
Expand Down Expand Up @@ -218,28 +218,38 @@ create_target_directory_groups(Xenon)

# Test compiler ID
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(MSVC True)
set(MSVC True)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(GCC True)
set(GCC True)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(Clang True)
set(Clang True)
endif()

# Copy fonts to build directory
add_custom_target(copy-fonts
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/Deps/fonts" # Input
"${CMAKE_CURRENT_BINARY_DIR}/fonts" # Output
COMMENT "Copying fonts (${CMAKE_CURRENT_SOURCE_DIR}/Deps/fonts) to build directory (${CMAKE_CURRENT_BINARY_DIR}/fonts)"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Deps/fonts
)

# Include OPENGL Directory
include_directories(Xenon third_party/glad/include)

add_dependencies(Xenon copy-fonts)
target_include_directories(Xenon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${IMGUI_DIR})
target_link_libraries(Xenon PRIVATE fmt::fmt SDL3::SDL3 toml11::toml11)

add_definitions(-DNTDDI_VERSION=0x0A000006 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)

if (MSVC)
set(CMAKE_GENERATOR_PLATFORM x64)
set(CMAKE_SYSTEM_VERSION 10.0.19041.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_GENERATOR_PLATFORM x64)
set(CMAKE_SYSTEM_VERSION 10.0.19041.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()

if (WIN32)
target_sources(Xenon PRIVATE Xenon/Xenon.rc)
endif()
target_sources(Xenon PRIVATE Xenon/Xenon.rc)
endif()
293 changes: 215 additions & 78 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,218 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-debug",
"displayName": "x86 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-release",
"displayName": "x86 Release",
"inherits": "x86-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-debug",
"displayName": "Linux Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
"version": 3,
"configurePresets": [
{
"name": "windows-clang-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "windows-msvc-base",
"hidden": true,
"generator": "Visual Studio 17 2022",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-clang-debug",
"displayName": "x64-Clang-Debug",
"inherits": "windows-clang-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-clang-release",
"displayName": "x64-Clang-Release",
"inherits": "x64-clang-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-clang-relwithdebinfo",
"displayName": "x64-Clang-RelWithDebInfo",
"inherits": "x64-clang-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x64-msvc-debug",
"displayName": "x64-MSVC-Debug",
"inherits": "windows-msvc-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-msvc-release",
"displayName": "x64-MSVC-Release",
"inherits": "x64-msvc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-msvc-relwithdebinfo",
"displayName": "x64-MSVC-RelWithDebInfo",
"inherits": "x64-msvc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x86-msvc-debug",
"displayName": "x86-MSVC-Debug",
"inherits": "windows-msvc-base",
"architecture": {
"value": "Win32",
"strategy": "set"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-msvc-release",
"displayName": "x86-MSVC-Release",
"inherits": "x86-msvc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-msvc-relwithdebinfo",
"displayName": "x86-MSVC-RelWithDebInfo",
"inherits": "x86-msvc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x86-clang-debug",
"displayName": "x86-Clang-Debug",
"inherits": "windows-clang-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-clang-release",
"displayName": "x86-Clang-Release",
"inherits": "x86-clang-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-Clang-relwithdebinfo",
"displayName": "x86-Clang-RelWithDebInfo",
"inherits": "x86-clang-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "linux-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
]
}
},
{
"name": "x64-linux-debug",
"displayName": "x64-Linux-Debug",
"inherits": "linux-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-linux-release",
"displayName": "x64-Linux-Release",
"inherits": "x64-linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-linux-relwithdebinfo",
"displayName": "x64-Linux-RelWithDebInfo",
"inherits": "x64-linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x86-linux-debug",
"displayName": "x86-Linux-Debug",
"inherits": "linux-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-linux-release",
"displayName": "x86-Linux-Release",
"inherits": "x86-linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-linux-relwithdebinfo",
"displayName": "x86-Linux-RelWithDebInfo",
"inherits": "x86-linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
}
]
}
15 changes: 15 additions & 0 deletions Deps/Building/building-linux-msvc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Compiling Xenon with Visual Studio 2022 and WSL CMake Deploy
### Now, this is by no means the best way to do it, it is certainly *a* way
### Prerequisites
* WSL2 with Ubuntu 24.04 or higher
* WSL2 configured to have X11 support
* Visual Studio 2022 with CMake support, and Linux support
* A lot of sanity and luck
### Setup
#### First, you need to satisfy dependencies for Ubuntu, which follows the same steps above
Then you need to satisfy MSBuild which Microsoft has a build dependency list for ['Targeting Linux using VS2022 and WSL2'](https://learn.microsoft.com/en-us/cpp/build/walkthrough-build-debug-wsl2?view=msvc-170)
### This should pretty much be it, just open the project as a local folder and set the target
If it prompts you to load the CMake files, **please** do so otherwise this **will NOT** work.
### How to run
#### By default, it will copy to ~/.vs/xenon/build/${target}
You will need to modify xenon_config.toml to point to the proper paths. I recommend copying your Xbox folder to your home folder, but if you don't want to, then you can just change `C:` to `/mnt/c`
Loading

0 comments on commit 62570a4

Please sign in to comment.