Added GTK3/SDL2 based fceux build capability into cmake build file. It is configurable from the command line which GUI to build GTK or QT (default).

This commit is contained in:
mjbudd77 2020-08-07 13:23:43 -04:00
parent 27875aac17
commit d416ceb0c4
1 changed files with 56 additions and 9 deletions

View File

@ -1,9 +1,12 @@
if ( ${GTK} )
set( APP_NAME fceux-gtk)
else()
set( APP_NAME fceux)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set( APP_NAME fceux)
endif()
if(WIN32)
set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_WIN})
@ -27,14 +30,22 @@ else(WIN32)
# Use the built-in cmake find_package functions to find dependencies
# Use package PkgConfig to detect headers/library what find_package cannot find.
find_package(PkgConfig REQUIRED)
find_package(Qt5 COMPONENTS Widgets OpenGL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(ZLIB REQUIRED)
add_definitions( ${Qt5Widgets_DEFINITIONS} )
include_directories( ${Qt5Widgets_INCLUDE_DIRS} )
add_definitions( -Wall -Wno-write-strings -Wno-sign-compare -Wno-parentheses -Wno-unused-local-typedefs -fPIC )
add_definitions( -D__QT_DRIVER__ -Wall -Wno-write-strings -Wno-sign-compare -Wno-parentheses -Wno-unused-local-typedefs -fPIC -DQT_DEPRECATED_WARNINGS )
if ( ${GTK} )
pkg_check_modules( GTK3 REQUIRED gtk+-3.0)
pkg_check_modules( X11 REQUIRED x11)
add_definitions( ${GTK3_CFLAGS} ${X11_CFLAGS} )
add_definitions( -D_GTK -DOPENGL )
else(${GTK})
find_package(Qt5 COMPONENTS Widgets OpenGL REQUIRED)
add_definitions( ${Qt5Widgets_DEFINITIONS} )
include_directories( ${Qt5Widgets_INCLUDE_DIRS} )
add_definitions( -D__QT_DRIVER__ -DQT_DEPRECATED_WARNINGS )
endif()
# Check for libminizip
pkg_check_modules( MINIZIP REQUIRED minizip)
@ -381,6 +392,24 @@ set(SRC_DRIVERS_COMMON
${CMAKE_CURRENT_SOURCE_DIR}/drivers/videolog/rgbtorgb.cpp
)
if ( ${GTK} )
set(SRC_DRIVERS_SDL
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/cheat.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/debugger.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/glxwin.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/gui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/input.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/memview.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/ramwatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/sdl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/sdl-joystick.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/sdl-sound.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/sdl-throttle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/sdl-video.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/sdl/unix-netplay.cpp
)
else()
set(SRC_DRIVERS_SDL
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleWindow.cpp
@ -407,6 +436,7 @@ set(SRC_DRIVERS_SDL
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/sdl-throttle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/unix-netplay.cpp
)
endif()
set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_SDL})
@ -427,11 +457,27 @@ add_executable( ${APP_NAME} MACOSX_BUNDLE ${APP_ICON} ${SOURCES} ../resources.
${CMAKE_CURRENT_BINARY_DIR}/fceux_git_info.cpp)
else()
add_executable( ${APP_NAME} ${SOURCES} ../resources.qrc
${CMAKE_CURRENT_BINARY_DIR}/fceux_git_info.cpp)
if ( ${GTK} )
add_executable( ${APP_NAME} ${SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/fceux_git_info.cpp)
else()
add_executable( ${APP_NAME} ${SOURCES} ../resources.qrc
${CMAKE_CURRENT_BINARY_DIR}/fceux_git_info.cpp)
endif()
endif()
target_link_libraries( fceux
if ( ${GTK} )
target_link_libraries( ${APP_NAME}
${GTK3_LDFLAGS} ${X11_LDFLAGS}
${OPENGL_LDFLAGS}
${SDL2_LDFLAGS}
${MINIZIP_LDFLAGS} ${ZLIB_LIBRARIES}
${LUA_LDFLAGS}
${SYS_LIBS}
)
else()
target_link_libraries( ${APP_NAME}
${Qt5Widgets_LIBRARIES}
${Qt5OpenGL_LIBRARIES}
${OPENGL_LDFLAGS}
@ -440,6 +486,7 @@ target_link_libraries( fceux
${LUA_LDFLAGS}
${SYS_LIBS}
)
endif()
if (APPLE)