Skip to content

Commit

Permalink
cmake test
Browse files Browse the repository at this point in the history
  • Loading branch information
invertego authored and jcm93 committed Oct 31, 2024
1 parent c287c1b commit dae71a4
Show file tree
Hide file tree
Showing 37 changed files with 1,337 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.vs/
.vscode/
.idea/
build*/
cmake-*/
obj/
out/
Expand Down
96 changes: 96 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
cmake_minimum_required(VERSION 3.14...3.27)

project(
ares
VERSION 0.134
DESCRIPTION "ares is a cross-platform, open source, multi-system emulator, focusing on accuracy and preservation."
LANGUAGES C CXX)

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(build optimized)
set(threaded TRUE)
set(openmp FALSE)
set(vulkan TRUE)
set(local TRUE)
set(lto TRUE)
set(console FALSE)

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()

#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}")

include_directories(.) #global

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

add_subdirectory(ares)
add_subdirectory(mia)
add_subdirectory(desktop-ui)
add_subdirectory(tests/i8080)
if(NOT WIN32)
add_subdirectory(tools/genius)
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)
126 changes: 126 additions & 0 deletions ares/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
add_library(ares STATIC
ares/ares.cpp
ares/memory/fixed-allocator.cpp
)

target_include_directories(ares PUBLIC .)

target_link_libraries(ares
PUBLIC libco sljit nall
PRIVATE thirdparty ymfm
)

if(platform STREQUAL windows)
# target_link_libraries(ares PRIVATE uuid kernel32 user32 gdi32 comctl32 comdlg32 shell32)
elseif(platform STREQUAL macos)
elseif(platform STREQUAL linux OR platform STREQUAL bsd)
# target_link_options(ares PRIVATE LINKER:-export-dynamic)
# target_link_libraries(ares PRIVATE X11 Xext)
else()
message(FATAL_ERROR "ares is a library and cannot be built directly.")
endif()

if(platform STREQUAL macos)
# set(ares.dylibs "")
endif()

if(vulkan)
target_compile_definitions(ares PUBLIC VULKAN)
endif()

if(profile STREQUAL accuracy)
target_compile_definitions(ares PUBLIC PROFILE_ACCURACY)
endif()

if(profile STREQUAL performance)
target_compile_definitions(ares PUBLIC PROFILE_PERFORMANCE)
endif()

macro(ares_components)
list(APPEND ares.components ${ARGV})
set(ares.components ${ares.components} PARENT_SCOPE)
endmacro()

if(a26 IN_LIST cores)
add_subdirectory(a26)
endif()

if(fc IN_LIST cores)
add_subdirectory(fc)
endif()

if(sfc IN_LIST cores)
add_subdirectory(sfc)
endif()

if(n64 IN_LIST cores)
add_subdirectory(n64)
endif()

if(sg IN_LIST cores)
add_subdirectory(sg)
endif()

if(ms IN_LIST cores)
add_subdirectory(ms)
endif()

if(md IN_LIST cores)
add_subdirectory(md)
endif()

if(saturn IN_LIST cores)
add_subdirectory(saturn)
endif()

if(ps1 IN_LIST cores)
add_subdirectory(ps1)
endif()

if(pce IN_LIST cores)
add_subdirectory(pce)
endif()

if(msx IN_LIST cores)
add_subdirectory(msx)
endif()

if(cv IN_LIST cores)
add_subdirectory(cv)
endif()

if(myvision IN_LIST cores)
add_subdirectory(myvision)
endif()

if(gb IN_LIST cores)
add_subdirectory(gb)
endif()

if(gba IN_LIST cores)
add_subdirectory(gba)
endif()

if(ws IN_LIST cores)
add_subdirectory(ws)
endif()

if(ng IN_LIST cores)
add_subdirectory(ng)
endif()

if(ngp IN_LIST cores)
add_subdirectory(ngp)
endif()

if(spec IN_LIST cores)
add_subdirectory(spec)
endif()

add_subdirectory(component)

foreach(c IN LISTS cores)
target_compile_definitions(ares PUBLIC CORE_$<UPPER_CASE:${c}>)
endforeach()

add_sourcery_command(ares ares/resource)
12 changes: 12 additions & 0 deletions ares/a26/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ares_components(
mos6502
)

target_sources(ares PRIVATE
system/system.cpp
controller/controller.cpp
cartridge/cartridge.cpp
cpu/cpu.cpp
tia/tia.cpp
riot/riot.cpp
)
44 changes: 44 additions & 0 deletions ares/component/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
list(REMOVE_DUPLICATES ares.components)

function(component_sources component)
if(component IN_LIST ares.components)
target_sources(ares PRIVATE ${ARGN})
endif()
endfunction()

component_sources(ay38910 audio/ay38910/ay38910.cpp)
component_sources(msm5205 audio/msm5205/msm5205.cpp)
component_sources(sn76489 audio/sn76489/sn76489.cpp)
component_sources(t6w28 audio/t6w28/t6w28.cpp)
component_sources(ym2149 audio/ym2149/ym2149.cpp)
component_sources(ym2413 audio/ym2413/ym2413.cpp)
component_sources(ym2612 audio/ym2612/ym2612.cpp)

component_sources(m24c eeprom/m24c/m24c.cpp)
component_sources(m93lcx6 eeprom/m93lcx6/m93lcx6.cpp)

component_sources(i8255 io/i8255/i8255.cpp)

component_sources(arm7tdmi processor/arm7tdmi/arm7tdmi.cpp)
component_sources(gsu processor/gsu/gsu.cpp)
component_sources(hg51b processor/hg51b/hg51b.cpp)
component_sources(huc6280 processor/huc6280/huc6280.cpp)
component_sources(i8080 processor/i8080/i8080.cpp)
component_sources(m68hc05 processor/m68hc05/m68hc05.cpp)
component_sources(m68000 processor/m68000/m68000.cpp)
component_sources(mos6502 processor/mos6502/mos6502.cpp)
component_sources(sh2 processor/sh2/sh2.cpp)
component_sources(sm5k processor/sm5k/sm5k.cpp)
component_sources(sm83 processor/sm83/sm83.cpp)
component_sources(spc700 processor/spc700/spc700.cpp)
component_sources(ssp1601 processor/ssp1601/ssp1601.cpp)
component_sources(tlcs900h processor/tlcs900h/tlcs900h.cpp)
component_sources(upd96050 processor/upd96050/upd96050.cpp)
component_sources(v30mz processor/v30mz/v30mz.cpp)
component_sources(wdc65816 processor/wdc65816/wdc65816.cpp)
component_sources(z80 processor/z80/z80.cpp)

component_sources(sst39sf0x0 flash/sst39sf0x0/sst39sf0x0.cpp)

component_sources(tms9918 video/tms9918/tms9918.cpp)
component_sources(v9938 video/v9938/v9938.cpp)
14 changes: 14 additions & 0 deletions ares/cv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ares_components(
z80
tms9918
sn76489
)

target_sources(ares PRIVATE
cpu/cpu.cpp
vdp/vdp.cpp
psg/psg.cpp
system/system.cpp
cartridge/cartridge.cpp
controller/controller.cpp
)
18 changes: 18 additions & 0 deletions ares/fc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ares_components(
mos6502
ym2149
ym2413
m24c
sst39sf0x0
)

target_sources(ares PRIVATE
system/system.cpp
controller/controller.cpp
expansion/expansion.cpp
cartridge/cartridge.cpp
cpu/cpu.cpp
apu/apu.cpp
ppu/ppu.cpp
fds/fds.cpp
)
13 changes: 13 additions & 0 deletions ares/gb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ares_components(
sm83
m93lcx6
)

target_sources(ares PRIVATE
system/system.cpp
cartridge/cartridge.cpp
bus/bus.cpp
cpu/cpu.cpp
ppu/ppu.cpp
apu/apu.cpp
)
13 changes: 13 additions & 0 deletions ares/gba/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ares_components(
arm7tdmi
)

target_sources(ares PRIVATE
memory/memory.cpp
system/system.cpp
cartridge/cartridge.cpp
player/player.cpp
cpu/cpu.cpp
ppu/ppu.cpp
apu/apu.cpp
)
22 changes: 22 additions & 0 deletions ares/md/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ares_components(
m68000
z80
sh2
ssp1601
sn76489
ym2612
m24c
)

target_sources(ares PRIVATE
bus/bus.cpp
cpu/cpu.cpp
apu/apu.cpp
vdp/vdp.cpp
opn2/opn2.cpp
m32x/m32x.cpp
mcd/mcd.cpp
system/system.cpp
cartridge/cartridge.cpp
controller/controller.cpp
)
16 changes: 16 additions & 0 deletions ares/ms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ares_components(
z80
sn76489
ym2413
)

target_sources(ares PRIVATE
cpu/cpu.cpp
vdp/vdp.cpp
psg/psg.cpp
opll/opll.cpp
system/system.cpp
cartridge/cartridge.cpp
controller/controller.cpp
expansion/expansion.cpp
)
Loading

0 comments on commit dae71a4

Please sign in to comment.