-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: add infrastructure, macOS, Windows, Linux builds
- Loading branch information
Showing
136 changed files
with
7,260 additions
and
1,109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"version": 3, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 28, | ||
"patch": 0 | ||
}, | ||
"configurePresets": [ | ||
{ | ||
"name": "environmentVars", | ||
"hidden": true, | ||
"cacheVariables": { | ||
"ARES_PROFILE_ACCURACY": false, | ||
"ENABLE_VULKAN": true, | ||
"ARES_BUILD_LOCAL": true, | ||
"ENABLE_CCACHE": false | ||
} | ||
}, | ||
{ | ||
"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": false | ||
} | ||
}, | ||
{ | ||
"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": false | ||
} | ||
}, | ||
{ | ||
"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": false | ||
} | ||
} | ||
], | ||
"buildPresets": [ | ||
{ | ||
"name": "windows", | ||
"configurePreset": "windows", | ||
"displayName": "Windows build (host architecture)", | ||
"description": "Windows build (host architecture)", | ||
"configuration": "RelWithDebInfo" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Legacy Build System | ||
|
||
### *nix building | ||
|
||
###### Minimum required packages: | ||
``` | ||
g++ make pkg-config libgtk-3-dev libcanberra-gtk-module libgl-dev libasound2-dev | ||
``` | ||
###### Additional Audio Drivers | ||
ares supports additional audio drivers besides the ALSA drivers included above. Installing these additional packages will allow them to be selected in Settings > Drivers: | ||
`libao-dev libopenal-dev` | ||
|
||
###### GTK2 & GTK3 | ||
By default, GTK3 is used, but support for GTK2 is available. You will need to install the additional package `libgtk2.0-dev` as well as specifying the command line option `hiro=gtk2` at compile time. | ||
|
||
###### SDL2 for input | ||
If you would like to use SDL for input (e.g. for using a controller), you will need to install the `libsdl2-dev` and `libsdl2-2.0-0` packages and perform a clean build of ares. | ||
You should then be able to select SDL for input in the Settings > Drivers menu. | ||
|
||
##### Building with clang | ||
|
||
clang++ is now the preferred compiler for ares. If clang is detected on Windows/macOS/BSD, it will be selected by default. On Linux and other platforms, g++ remains the default if present. To build with clang, it is necessary to install both the `clang` and `lld` packages. If you would like to manually specify a compiler, you can use the following option: `compiler=[g++|clang++]` | ||
|
||
##### Librashader Support | ||
If you do not want to include librashader support, you can pass the following option to the `make` command to skip these requirements using: `librashader=false` | ||
|
||
Librashader requires rust in order to build. You can install it with the following command: | ||
``` | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | ||
source ~/.cargo/env | ||
rustup toolchain install nightly | ||
``` | ||
|
||
In order to build librashader, change into the `ares/thirdparty/librashader` directory and run the script `build-librashader.sh` | ||
Note that once the build completes, it will instruct you to run three copy commands to install the library on your system. These paths may be different depending on Linux distribution. | ||
|
||
-------------- | ||
|
||
### Windows building | ||
|
||
To build on Windows, using MSYS2 is recommended which can be download [here](https://www.msys2.org/). Follow the instructions | ||
on this page to install and setup an appropriate MINGW64 environment. Running the command: | ||
``` | ||
pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-SDL2 | ||
``` | ||
from the MSYS2 MSYS terminal should setup everything you need to compile ares. Note that in order to compile, you will want to be in a MINGW64 terminal window after install and setup is complete. | ||
|
||
##### Building with clang | ||
|
||
clang is available through Visual Studio (or Build Tools for Visual Studio) through its installer and can be used to build ares. You will still need to supply GNU make in this instance. MSYS2 also offers a clang environment. You will want to make sure you select the clangw64 option during installation of MSYS2 which should provide and additional CLANG64 pre-configured environment. Install the clang toolchain package from the MSYS2 terminal: | ||
``` | ||
pacman -S mingw-w64-clang-x86_64-toolchain mingw-w64-clang-x86_64-SDL2 | ||
``` | ||
Once complete, open a CLANG64 terminal window and proceed with building ares. | ||
|
||
###### Debug Symbols | ||
When building with clang, by default symbols will be generated for debug builds using an MSVC compatible format (CodeView) for use with Windows debugging tools. In order to generate GDB compatible symbols, specify the following option: `symformat=gdb` | ||
|
||
###### Librashader Support | ||
ares has introduced support for the [librashader](https://github.com/SnowflakePowered/librashader) library, which is a preprocessor, compiler, and runtime for RetroArch 'slang' shaders. If you are not interested in working with librashaders, you can pass the following option to the `make` command to skip these requirements using: `librashader=false` | ||
|
||
Building the librashader library on Windows requires Rust. Follow these steps to prepare your system and build the librashader library: | ||
|
||
1. Download and execute the rustup-init.exe installer from: https://rustup.rs/ | ||
2. Open a new Windows terminal and run the following commands: | ||
``` | ||
rustup toolchain install nightly | ||
rustup default nightly | ||
``` | ||
3. With Rust successfully installed, you will need to update your PATH environment variable within your MSYS2 environment. In an MSYS2 shell, open $HOME/.bash_profile and append something like the following (note you will need to replace both instances of %USER_NAME% with the real user name you used to install Rust): | ||
``` | ||
if [ -d "/C/Users/%USER_NAME%/.cargo/bin" ] ; then | ||
PATH="/C/Users/%USER_NAME%/.cargo/bin:${PATH}" | ||
fi | ||
``` | ||
4. Open a new MSYS2 based shell for the compiler you are using (MinGW64|CLANG64|UCRT64), execute `rustup` to validate the path is set properly within your MSYS2 environment. | ||
5. In your MSYS2 compiler shell, `cd` into the `ares/thirdparty/librashader` directory | ||
6. Execute the build script, build should complete successfully: | ||
``` | ||
./build-librashader.sh | ||
``` | ||
This only needs to be done once, or anytime the librashader library is updated. Once built, ares will build with librashader support by default requiring no additional flags. | ||
Compilation | ||
----------- | ||
Check out the source code by running this command: | ||
``` | ||
git clone https://github.com/ares-emulator/ares.git | ||
``` | ||
From the root of the project directory run: | ||
``` | ||
make -j4 | ||
``` | ||
`-j#` indicates number of parallel build processes, and shouldn't be set higher than N-1 cores on your processor. Specifying this option can significantly decrease the time to build this project. There are multiple build types available and it defaults to an 'optimized' build. Build types can be specified using: `build=[debug|stable|release|minified|optimized]` | ||
Build options can be found in the following two make files: nall/GNUmakefile desktop-ui/GNUmakefile | ||
To start compilation from the beginning, run the following prior to compiling: | ||
``` | ||
make clean | ||
``` | ||
#### Building specific cores | ||
If you would like to build a subset of cores, you can specify the `cores="core1 core2"` option. Currently available cores: | ||
``` | ||
a26 fc sfc n64 sg ms md ps1 pce ng msx cv myvision gb gba ws ngp spec | ||
``` | ||
Build Output | ||
------------ | ||
There is a single binary produced at the end of compilation which can be found in `desktop-ui/out`. On OS's besides Linux, the `Database` & `Shader` directories are copied over here as well. On Linux, running `make install` after compilation will copy these directories and binary into suitable locations (see desktop-ui/GNUmakefile for details). Alternatively, these directories can be copied from `thirdparty/slang-shaders/*` into a `Shader` directory, and by copying `mia/Database/*` | ||
Oops, something went wrong.