Skip to content

Commit

Permalink
CMake: Add infrastructure and builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 committed Nov 6, 2024
1 parent 9f658a6 commit 3114227
Show file tree
Hide file tree
Showing 139 changed files with 7,373 additions and 1,118 deletions.
11 changes: 11 additions & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json

color: false
definitions: [ares/CMakeLists.txt]
line_length: 120
indent: 2
list_expansion: favour-inlining
quiet: false
unsafe: false
warn_about_unknown_commands: false
workers: 10
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto

*.cpp text
54 changes: 37 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
*.moc
*.user
*.xcuserdata
.vs/
.vscode/
.idea/
build*/
cmake-*/
obj/
out/
obj-amd64/
obj-arm64/
out-amd64/
out-arm64/
# Exclude everything
/*

# Except for default project files
!/.github
!/ares
!/desktop-ui
!/hiro
!/cmake
!/libco
!/mia
!/nall
!/ruby
!/scripts
!/tests/i8080
!/thirdparty
!/tools
!/GNUMakefile
!/LICENSE
!/README.md
!/Legacy Build System.md
!.editorconfig
!.gitignore
!.gitattributes
!.gersemirc
!deps.json
!CMakeLists.txt
!CMakePresets.json

thirdparty/SDL/SDL
thirdparty/SDL/libSDL2-2.0.0.dylib
macos-xcode/
.swiftpm
*.xcodeproj
ruby/video/metal/shaders.metallib
ruby/video/metal/shaders.ir
# ares/ares/resource/resource.cpp
# ares/ares/resource/resource.hpp
# hiro/resource/resource.cpp
# hiro/resource/resource.hpp
# desktop-ui/resource/resource.cpp
# desktop-ui/resource/resource.hpp
96 changes: 22 additions & 74 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,96 +1,44 @@
cmake_minimum_required(VERSION 3.14...3.27)
cmake_minimum_required(VERSION 3.28...3.30)

project(
ares
VERSION 0.134
DESCRIPTION "ares is a cross-platform, open source, multi-system emulator, focusing on accuracy and preservation."
LANGUAGES C CXX)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)

if(WIN32 AND NOT MINGW)
add_compile_definitions(EXCLUDE_MANIFEST_FROM_RC) #global
endif()

function(add_sourcery_command target subdir)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/resource.cpp ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/resource.hpp
COMMAND sourcery resource.bml resource.cpp resource.hpp
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/resource.bml
VERBATIM
)
add_custom_target(${target}-resource DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/resource.cpp ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/resource.hpp)
add_dependencies(${target} ${target}-resource)
endfunction()

add_subdirectory(thirdparty)
set(CMAKE_SUPPRESS_REGENERATION true)

set(build optimized)
set(threaded TRUE)
set(openmp FALSE)
set(vulkan TRUE)
set(local TRUE)
set(lto TRUE)
set(console FALSE)
project(ares VERSION ${ARES_VERSION_CANONICAL})

set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
include(compilerconfig)
include(defaults)
include(helpers)

#for now, derive build type from cmake standard build type
set(build $<$<CONFIG:Debug>:debug>$<$<CONFIG:Release>:optimized>$<$<CONFIG:RelWithDebInfo>:release>$<$<CONFIG:MinSizeRel>:minified>)
#file(GENERATE OUTPUT build_$<CONFIG>.txt CONTENT "build = ${build}")
add_subdirectory(cmake)

include_directories(.) #global
add_subdirectory(thirdparty)

add_subdirectory(nall)

if(arch STREQUAL x86 OR arch STREQUAL amd64)
if(NOT MSVC)
if(local)
add_compile_options(-march=native) #global
else()
# For official builds, default to x86-64-v2 (Intel Nehalem, AMD Bulldozer) which supports up to SSE 4.2.
add_compile_options(-march=x86-64-v2) #global
endif()
endif()
endif()

add_subdirectory(libco)
add_subdirectory(ruby)

#hiro.resource := resource/ares.rc
add_subdirectory(hiro)

set(profile performance)
set(cores n64 ng spec)
#set(cores a26 fc sfc n64 sg ms md ps1 pce ng msx cv myvision gb gba ws ngp spec) #saturn
# gersemi: off
set(
ARES_CORES
a26 fc sfc sg ms md ps1 pce ng msx cv myvision gb gba ws ngp spec n64
CACHE INTERNAL LIST
)
# gersemi: on

add_subdirectory(ares)
add_subdirectory(mia)
add_subdirectory(desktop-ui)

add_subdirectory(tests/i8080)
if(NOT WIN32)
if(NOT OS_WINDOWS AND NOT OS_MACOS)
add_subdirectory(tools/genius)
else()
target_disable_subproject(genius "genius (database editor)")
endif()
add_subdirectory(tools/mame2bml)
add_subdirectory(tools/sourcery)


set_target_properties(
ares
hiro
libco
mia
nall
ruby
desktop-ui
libchdr
sljit
tzxfile
ymfm
PROPERTIES VS_GLOBAL_VcpkgEnabled false)
message_configuration()
return()
81 changes: 81 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 28,
"patch": 0
},
"configurePresets": [
{
"name": "environmentVars",
"hidden": true,
"cacheVariables": {
"ARES_PROFILE_ACCURACY": false,
"ARES_BUILD_LOCAL": true,
"ENABLE_CCACHE": true
}
},
{
"name": "macos",
"displayName": "macOS",
"description": "Xcode project (host architecture by default)",
"inherits": ["environmentVars"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"generator": "Xcode",
"binaryDir": "${sourceDir}/build_macos",
"cacheVariables": {
"CMAKE_OSX_DEPLOYMENT_TARGET": {"type": "STRING", "value": "10.13"},
"ARES_CODESIGN_IDENTITY": {"type": "STRING", "value": "$penv{CODESIGN_IDENT}"},
"ARES_CODESIGN_TEAM": {"type": "STRING", "value": "$penv{CODESIGN_TEAM}"},
"ENABLE_COMPILER_TRACE": true,
"ENABLE_CCACHE": true
}
},
{
"name": "windows",
"displayName": "Windows (Visual Studio, ClangCL)",
"description": "Visual Studio project using ClangCL (host architecture)",
"inherits": ["environmentVars"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"binaryDir": "${sourceDir}/build_vsclang",
"generator": "Visual Studio 17 2022",
"toolset": "ClangCL",
"cacheVariables": {
"ENABLE_CCACHE": true
}
},
{
"name": "windows-msvc",
"displayName": "Windows (Visual Studio, MSVC)",
"description": "Visual Studio project using MSVC (host architecture)",
"inherits": ["environmentVars"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"binaryDir": "${sourceDir}/build_msvc",
"generator": "Visual Studio 17 2022",
"cacheVariables": {
"ENABLE_CCACHE": true
}
}
],
"buildPresets": [
{
"name": "windows",
"configurePreset": "windows",
"displayName": "Windows build (host architecture)",
"description": "Windows build (host architecture)",
"configuration": "RelWithDebInfo"
}
]
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
----------------------------------------------------------------------
ares

Copyright (c) 2004-2021 ares team, Near et al
Copyright (c) 2004-2024 ares team, Near et al

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
Expand Down
Loading

0 comments on commit 3114227

Please sign in to comment.