2019-04-12 20:59:39 +00:00
cmake_minimum_required ( VERSION 3.5.0 FATAL_ERROR )
set ( TNAME reicast )
project ( ${ TNAME } )
enable_language ( ASM )
2019-05-16 10:05:16 +00:00
enable_language ( ASM_MASM )
2019-04-12 20:59:39 +00:00
set ( DEBUG_CMAKE ON )
set ( CMAKE_VERBOSE_MAKEFILE ON )
set ( CMAKE_INCLUDE_CURRENT_DIR ON )
set ( reicast_root_path "${CMAKE_CURRENT_SOURCE_DIR}" )
set ( reicast_core_path "${reicast_root_path}/core" )
set ( reicast_shell_path "${reicast_root_path}/shell" )
list ( APPEND CMAKE_MODULE_PATH "${reicast_shell_path}/cmake" )
include ( GetGitRevisionDescription )
git_describe ( GIT_VERSION --tags )
configure_file ( ${ reicast_core_path } /version.h.in ${ reicast_core_path } /version.h @ONLY )
## reicast build modules #
#
set ( reicast_SRCS "" )
include ( config ) # configure build settings, must be first
### libdreamcast.cmake #########################################################################
set ( d_core ${ reicast_core_path } )
file ( GLOB_RECURSE hw_SRCS ${ d_core } /hw/*.cpp ${ d_core } /hw/*.h )
file ( GLOB cfg_SRCS ${ d_core } /cfg/*.cpp ${ d_core } /cfg/*.h )
file ( GLOB rend_SRCS ${ d_core } /rend/*.cpp ${ d_core } /rend/*.h )
file ( GLOB input_SRCS ${ d_core } /input/*.cpp ${ d_core } /input/*.h )
file ( GLOB reios_SRCS ${ d_core } /reios/*.cpp ${ d_core } /reios/*.h )
file ( GLOB imgread_SRCS ${ d_core } /imgread/*.cpp ${ d_core } /imgread/*.h )
file ( GLOB profiler_SRCS ${ d_core } /profiler/*.cpp ${ d_core } /profiler/*.h )
file ( GLOB archive_SRCS ${ d_core } /archive/*.cpp ${ d_core } /archive/*.h )
#### option(rend)
file ( GLOB gl4_SRCS ${ d_core } /rend/gl4/*.cpp ${ d_core } /rend/gl4/*.h )
file ( GLOB gles_SRCS ${ d_core } /rend/gles/*.cpp ${ d_core } /rend/gles/*.h )
set ( core_SRCS
$ { h w _ S R C S }
$ { c f g _ S R C S }
$ { r e n d _ S R C S }
$ { g l 4 _ S R C S }
$ { g l e s _ S R C S }
$ { i n p u t _ S R C S }
$ { r e i o s _ S R C S }
$ { i m g r e a d _ S R C S }
$ { p r o f i l e r _ S R C S }
$ { d _ c o r e } / a r c h i v e / a r c h i v e . c p p $ { d _ c o r e } / a r c h i v e / a r c h i v e . h
$ { d _ c o r e } / n u l l D C . c p p
$ { d _ c o r e } / s t d c l a s s . c p p
$ { d _ c o r e } / d i s p f r a m e . c p p
$ { d _ c o r e } / s e r i a l i z e . c p p
)
2019-04-12 23:42:14 +00:00
if ( ${ BUILD_COMPILER } EQUAL ${ COMPILER_GCC } ) # Add Clang if NOT WIN32 *FIXME*
list ( APPEND core_SRCS ${ archive_SRCS } )
endif ( )
2019-04-12 20:59:39 +00:00
if ( ${ FEAT_SHREC } EQUAL ${ DYNAREC_JIT } )
#
if ( ${ HOST_CPU } EQUAL ${ CPU_X86 } )
list ( APPEND core_SRCS
$ { d _ c o r e } / r e c - x 8 6 / r e c _ x 8 6 _ d r i v e r . c p p
$ { d _ c o r e } / r e c - x 8 6 / r e c _ x 8 6 _ i l . c p p
$ { d _ c o r e } / r e c - x 8 6 / r e c _ x 8 6 _ a s m . c p p # change for linux , rec_lin86_asm.S
$ { d _ c o r e } / r e c - x 8 6 / r e c _ x 8 6 _ n g e n . h
)
elseif ( ${ HOST_CPU } EQUAL ${ CPU_ARM } )
list ( APPEND core_SRCS
$ { d _ c o r e } / r e c - A R M / n g e n _ a r m . S
$ { d _ c o r e } / r e c - A R M / r e c _ a r m . c p p
)
elseif ( ${ HOST_CPU } EQUAL ${ CPU_X64 } )
### FIXME: asm with cmake ninja+VC
if ( ${ BUILD_COMPILER } EQUAL ${ COMPILER_VC } )
list ( APPEND core_SRCS ${ d_core } /rec-x64/msvc.asm )
endif ( )
list ( APPEND core_SRCS ${ d_core } /rec-x64/rec_x64.cpp ${ d_core } /rec-x64/x64_regalloc.h )
elseif ( ${ HOST_CPU } EQUAL ${ CPU_A64 } )
list ( APPEND core_SRCS ${ d_core } /rec-ARM64/rec_arm64.cpp ${ d_core } /rec-ARM64/arm64_regalloc.h )
else ( )
message ( " FEAT_SHREC==DYNAREC_JIT && HOST_CPU Unknown Default add arch or disable rec if not avail." )
error ( )
endif ( )
#
elseif ( ${ FEAT_SHREC } EQUAL ${ DYNAREC_CPP } )
list ( APPEND core_SRCS ${ d_core } /rec-cpp/rec_cpp.cpp )
endif ( )
add_definitions ( /DFEAT_HAS_SOFTREND=0 )
### deps.cmake #################################################################################
set ( d_deps ${ reicast_core_path } /deps )
include_directories ( "${d_deps}" )
include_directories ( "${d_deps}/picotcp/include" )
include_directories ( "${d_deps}/picotcp/modules" )
file ( GLOB xbyak_H ${ d_deps } /xbyak/*.h ) # include headers into cmake target/project view
file ( GLOB chdr_SRCS ${ d_deps } /chdr/*.c )
file ( GLOB lzma_SRCS ${ d_deps } /lzma/*.c )
file ( GLOB lz_SRCS ${ d_deps } /zlib/*.c )
file ( GLOB lzip_SRCS ${ d_deps } /libzip/*.c )
file ( GLOB lpng_SRCS ${ d_deps } /libpng/*.c )
file ( GLOB lelf_SRCS ${ d_deps } /libelf/el*.cpp )
file ( GLOB crypt_SRCS ${ d_deps } /crypto/*.cpp )
file ( GLOB imgui_SRCS ${ d_deps } /imgui/*.cpp )
file ( GLOB lws_SRCS ${ d_deps } /libwebsocket/*.c )
file ( GLOB picoModS ${ d_deps } /picotcp/modules/*.c )
file ( GLOB picoStkS ${ d_deps } /picotcp/stack/*.c )
set ( pico_SRCS ${ picoModS } ${ picoStkS } )
set ( deps_SRCS
$ { l z _ S R C S }
$ { l p n g _ S R C S }
$ { l e l f _ S R C S }
$ { c h d r _ S R C S }
$ { c r y p t _ S R C S }
$ { i m g u i _ S R C S }
$ { d _ d e p s } / x b r z / x b r z . c p p
$ { d _ d e p s } / d i r e n t / d i r e n t . c
$ { d _ d e p s } / x x h a s h / x x h a s h . c
$ { d _ d e p s } / c h d p s r / c d i p s r . c p p # sigh, this dir is named chdpsr for some reason ...
$ { d _ d e p s } / c o r e i o / c o r e i o . c p p
# ${d_deps}/ifaddrs/ifaddrs.c
$ { x b y a k _ H }
)
2019-04-12 23:42:14 +00:00
if ( ${ BUILD_COMPILER } EQUAL ${ COMPILER_GCC } ) # Add Clang if NOT WIN32 *FIXME*
list ( APPEND deps_SRCS
$ { l z i p _ S R C S }
$ { l z m a _ S R C S }
$ { p i c o _ S R C S }
)
2019-05-01 23:11:35 +00:00
add_definitions ( -D_7ZIP_ST -DCHD5_LZMA )
2019-04-12 23:42:14 +00:00
endif ( )
2019-04-12 20:59:39 +00:00
### libosd.cmake ################################################################################
set ( d_aout ${ reicast_core_path } /oslib )
include_directories ( "${d_core}/khronos" )
## I really should just glob all of the dirs and ;shrug; if guards don't do it all ##
set ( osd_SRCS "" )
list ( APPEND osd_SRCS ${ d_aout } /audiostream.cpp )
if ( ${ HOST_OS } EQUAL ${ OS_WINDOWS } )
list ( APPEND osd_SRCS ${ d_core } /windows/winmain.cpp )
2019-05-16 10:05:16 +00:00
list ( APPEND osd_SRCS ${ d_core } /windows/win_vmem.cpp )
2019-04-12 20:59:39 +00:00
list ( APPEND osd_SRCS ${ d_aout } /audiobackend_directsound.cpp )
2019-04-12 23:42:14 +00:00
link_libraries ( dsound.lib winmm.lib xinput.lib wsock32.lib opengl32.lib )
2019-04-12 20:59:39 +00:00
elseif ( ${ HOST_OS } EQUAL ${ OS_LINUX } OR ${ HOST_OS } EQUAL ${ OS_ANDROID } )
list ( APPEND osd_SRCS
$ { d _ c o r e } / l i n u x / c o m m o n . c p p
$ { d _ c o r e } / l i n u x / c o n t e x t . c p p
$ { d _ c o r e } / l i n u x / n i x p r o f / n i x p r o f . c p p
$ { d _ a o u t } / a u d i o b a c k e n d _ o s s . c p p # add option
) # todo: configure linux audio lib options
if ( NOT ANDROID )
list ( APPEND osd_SRCS
$ { d _ c o r e } / l i n u x - d i s t / x 1 1 . c p p
$ { d _ c o r e } / l i n u x - d i s t / m a i n . c p p
$ { d _ c o r e } / l i n u x - d i s t / e v d e v . c p p )
add_definitions ( -DSUPPORT_X11 ) ## don't use GLES ?
link_libraries ( X11 )
else ( )
list ( APPEND osd_SRCS
. / / a n d r o i d - s t u d i o / r e i c a s t / s r c / m a i n / j n i / s r c / A n d r o i d . c p p
. / / a n d r o i d - s t u d i o / r e i c a s t / s r c / m a i n / j n i / s r c / u t i l s . c p p
# .//android-studio/reicast/src/main/jni/src/XperiaPlay.c
)
endif ( ) # ANDROID
add_definitions ( -DGLES -DUSE_EVDEV )
link_libraries ( pthread dl rt asound Xext GLESv2 EGL )
elseif ( ${ HOST_OS } EQUAL ${ OS_DARWIN } )
#
list ( APPEND objc_SRCS
. / s h e l l / a p p l e / e m u l a t o r - o s x / e m u l a t o r - o s x / o s x - m a i n . m m
. / s h e l l / a p p l e / e m u l a t o r - o s x / e m u l a t o r - o s x / A p p D e l e g a t e . s w i f t
. / s h e l l / a p p l e / e m u l a t o r - o s x / e m u l a t o r - o s x / E m u G L V i e w . s w i f t
)
set_source_files_properties ( ${ objc_SRCS } PROPERTIES COMPILE_FLAGS "-x objective-c++" )
list ( APPEND osd_SRCS ${ objc_SRCS }
$ { d _ o s d } / l i n u x / c o m m o n . c p p
$ { d _ o s d } / l i n u x / c o n t e x t . c p p
$ { d _ o s d } / a u d i o b a c k e n d / a u d i o b a c k e n d _ c o r e a u d i o . c p p
# if NOT USE_SWIFT / ObjC
#${d_osd}/apple/osx_osd.cpp
)
else ( )
#
message ( "OS Unhandled" )
error ( )
#
endif ( )
2019-04-12 23:42:14 +00:00
##
include_directories ( "${reicast_core_path}" )
2019-04-12 20:59:39 +00:00
set ( reicast_SRCS ${ core_SRCS } ${ deps_SRCS } ${ osd_SRCS } )
add_executable ( ${ TNAME } ${ binSuffix } ${ reicast_SRCS } ${ deps_SRCS } )
if ( APPLE )
enable_language ( Swift )
set_property ( TARGET ${ TNAME } PROPERTY XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "./shell/apple/emulator-osx/emulator-osx/emulator-osx-Bridging-Header.h" )
target_link_libraries ( ${ TNAME }
# "-framework Cocoa"
# "-framework AppKit"
" - f r a m e w o r k C o r e D a t a "
" - f r a m e w o r k C o r e A u d i o "
" - f r a m e w o r k A u d i o U n i t "
" - f r a m e w o r k A u d i o T o o l b o x "
" - f r a m e w o r k F o u n d a t i o n "
)
#### OSX Notes, when not using xcode you have to make app bundle, edit plist and copy, convert MainMenu.xib to nib and copy,
#null@devpc:~$ /Users/null/Documents/projects/reicast-emulator/bin/RelWithDebInfo/Reicast.app/Contents/MacOS/reicast ; exit;
#2019-03-18 14:28:44.842 reicast[11468:131797] Unknown class _TtC12emulator_osx9EmuGLView in Interface Builder file at path /Users/null/Documents/projects/reicast-emulator/bin/RelWithDebInfo/Reicast.app/Contents/Resources/MainMenu.nib.
#2019-03-18 14:28:44.842 reicast[11468:131797] Unknown class _TtC12emulator_osx11AppDelegate in Interface Builder file at path /Users/null/Documents/projects/reicast-emulator/bin/RelWithDebInfo/Reicast.app/Contents/Resources/MainMenu.nib.
#2019-03-18 14:28:44.860 reicast[11468:131797] Failed to connect (window) outlet from (NSObject) to (NSWindow): missing setter or instance variable
#
endif ( ) #APPLE
if ( DEBUG_CMAKE )
message ( " ------------------------------------------------" )
message ( " - HOST_OS: ${HOST_OS} - HOST_CPU: ${HOST_CPU} " )
message ( " - host_os: ${host_os} - host_arch: ${host_arch} " )
message ( " ------------------------------------------------" )
message ( " C Flags: ${CMAKE_C_FLAGS} " )
message ( " CXX Flags: ${CMAKE_CXX_FLAGS} " )
message ( " LINK_DIRS: ${LINK_DIRECTORIES}" )
message ( "LINK_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}" )
message ( " ------------------------------------------------\n" )
endif ( )