Merge pull request #755 from magcius/clean-up-nogui

Allow building MainNoGUI and MainGUI simultaneously
This commit is contained in:
Lioncash 2014-08-06 22:39:57 -04:00
commit e0c5e05805
5 changed files with 94 additions and 97 deletions

View File

@ -5,8 +5,8 @@ cmake_minimum_required(VERSION 2.8)
option(ANDROID "Enables a build for Android" OFF) option(ANDROID "Enables a build for Android" OFF)
option(USE_EGL "Enables EGL OpenGL Interface" OFF) option(USE_EGL "Enables EGL OpenGL Interface" OFF)
option(USE_X11 "Enables X11 Support" ON) option(TRY_X11 "Enables X11 Support" ON)
option(USE_WAYLAND "Enables Wayland Support" OFF) option(TRY_WAYLAND "Enables Wayland Support" OFF)
option(USE_UPNP "Enables UPnP port mapping support" ON) option(USE_UPNP "Enables UPnP port mapping support" ON)
option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF) option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF)
option(ENABLE_PCH "Use PCH to speed up compilation" ON) option(ENABLE_PCH "Use PCH to speed up compilation" ON)
@ -326,27 +326,11 @@ if(ANDROID)
set(USE_X11 0) set(USE_X11 0)
set(USE_WAYLAND 0) set(USE_WAYLAND 0)
set(USE_UPNP 0) set(USE_UPNP 0)
set(USE_EGL True) set(USE_EGL 1)
add_definitions(-DUSE_EGL=1)
endif() endif()
include_directories(Externals/GL) include_directories(Externals/GL)
# For now Wayland and EGL are tied to each other.
# The alternative would be an shm path
if(USE_WAYLAND)
add_definitions(-DUSE_EGL)
set(USE_EGL 1)
endif()
if(USE_EGL)
message("EGL OpenGL interface enabled")
add_definitions(-DUSE_EGL=1)
else()
# Using GLX
set(USE_X11 1)
set(USE_WAYLAND 0)
endif()
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE) add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
######################################## ########################################
@ -422,11 +406,14 @@ if(NOT ANDROID)
message("OpenAL NOT found, disabling OpenAL sound backend") message("OpenAL NOT found, disabling OpenAL sound backend")
endif(OPENAL_FOUND) endif(OPENAL_FOUND)
set(USE_X11 0)
set(USE_WAYLAND 0)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
# Note: The convention is to check USE_X11 or USE_WAYLAND where needed. # Note: The convention is to check TRY_X11 or TRY_WAYLAND where needed.
# This is where we detect platforms and set the variables accordingly. # This is where we detect platforms and set the variables accordingly.
pkg_check_modules(WAYLAND wayland-egl wayland-client wayland-cursor) pkg_check_modules(WAYLAND wayland-egl wayland-client wayland-cursor)
if(USE_WAYLAND AND WAYLAND_FOUND) if(TRY_WAYLAND AND WAYLAND_FOUND)
pkg_check_modules(XKBCOMMON xkbcommon) pkg_check_modules(XKBCOMMON xkbcommon)
if(XKBCOMMON_FOUND) if(XKBCOMMON_FOUND)
set(USE_WAYLAND 1) set(USE_WAYLAND 1)
@ -438,11 +425,11 @@ if(NOT ANDROID)
set(USE_WAYLAND 0) set(USE_WAYLAND 0)
message("Wayland support disabled") message("Wayland support disabled")
add_definitions(-DHAVE_WAYLAND=0) add_definitions(-DHAVE_WAYLAND=0)
endif(USE_WAYLAND AND WAYLAND_FOUND) endif(TRY_WAYLAND AND WAYLAND_FOUND)
# Note: We do not need to explicitly check for X11 as it is done in the cmake # Note: We do not need to explicitly check for X11 as it is done in the cmake
# FindOpenGL module on linux. # FindOpenGL module on linux.
if(USE_X11 AND X11_FOUND) if(TRY_X11 AND X11_FOUND)
set(USE_X11 1) set(USE_X11 1)
add_definitions(-DHAVE_X11=1) add_definitions(-DHAVE_X11=1)
include_directories(${X11_INCLUDE_DIR}) include_directories(${X11_INCLUDE_DIR})
@ -452,7 +439,7 @@ if(NOT ANDROID)
SET(X11_FOUND "") SET(X11_FOUND "")
message("X11 support disabled") message("X11 support disabled")
add_definitions(-DHAVE_X11=0) add_definitions(-DHAVE_X11=0)
endif(USE_X11 AND X11_FOUND) endif(TRY_X11 AND X11_FOUND)
if (NOT USE_WAYLAND AND NOT USE_X11) if (NOT USE_WAYLAND AND NOT USE_X11)
message(FATAL_ERROR "\n" message(FATAL_ERROR "\n"
@ -461,6 +448,12 @@ if(NOT ANDROID)
endif() endif()
endif() endif()
# For now Wayland and EGL are tied to each other.
# The alternative would be an shm path
if(USE_WAYLAND)
set(USE_EGL 1)
endif()
if(USE_X11) if(USE_X11)
check_lib(XRANDR Xrandr) check_lib(XRANDR Xrandr)
if(XRANDR_FOUND) if(XRANDR_FOUND)
@ -508,6 +501,11 @@ if(NOT ANDROID)
endif() endif()
endif() endif()
if(USE_EGL)
message("EGL OpenGL interface enabled")
add_definitions(-DUSE_EGL=1)
endif()
######################################## ########################################
# Setup include directories (and make sure they are preferred over the Externals) # Setup include directories (and make sure they are preferred over the Externals)
# #

View File

@ -23,8 +23,7 @@ if(LIBAV_FOUND)
set(LIBS ${LIBS} ${LIBAV_LIBRARIES}) set(LIBS ${LIBS} ${LIBAV_LIBRARIES})
endif() endif()
if(wxWidgets_FOUND) set(GUI_SRCS
set(SRCS
ARCodeAddEdit.cpp ARCodeAddEdit.cpp
AboutDolphin.cpp AboutDolphin.cpp
CheatsWindow.cpp CheatsWindow.cpp
@ -70,15 +69,10 @@ if(wxWidgets_FOUND)
WiimoteConfigDiag.cpp WiimoteConfigDiag.cpp
WxUtils.cpp) WxUtils.cpp)
set(WXLIBS ${wxWidgets_LIBRARIES} dl) set(WXLIBS ${wxWidgets_LIBRARIES} dl)
else()
if(ANDROID) set(ANDROID_SRCS Android/ButtonManager.cpp
set(SRCS Android/ButtonManager.cpp
MainAndroid.cpp) MainAndroid.cpp)
else()
set(SRCS MainNoGUI.cpp)
endif()
endif()
if(USE_EGL) if(USE_EGL)
set(SRCS ${SRCS} GLInterface/Platform.cpp set(SRCS ${SRCS} GLInterface/Platform.cpp
@ -102,6 +96,8 @@ else()
endif() endif()
set(SRCS ${SRCS} GLInterface/GLInterface.cpp) set(SRCS ${SRCS} GLInterface/GLInterface.cpp)
set(NOGUI_SRCS MainNoGUI.cpp)
if(WIN32) if(WIN32)
set(SRCS ${SRCS} stdafx.cpp) set(SRCS ${SRCS} stdafx.cpp)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@ -140,11 +136,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
else() else()
set(DOLPHIN_EXE_BASE dolphin-emu) set(DOLPHIN_EXE_BASE dolphin-emu)
endif() endif()
if(wxWidgets_FOUND)
set(DOLPHIN_EXE ${DOLPHIN_EXE_BASE}) set(DOLPHIN_EXE ${DOLPHIN_EXE_BASE})
else()
set(DOLPHIN_EXE ${DOLPHIN_EXE_BASE}-nogui)
endif()
if(USE_UPNP) if(USE_UPNP)
set(LIBS ${LIBS} miniupnpc) set(LIBS ${LIBS} miniupnpc)
@ -159,7 +152,7 @@ endif()
if(ANDROID) if(ANDROID)
set(DOLPHIN_EXE main) set(DOLPHIN_EXE main)
add_library(${DOLPHIN_EXE} SHARED ${SRCS}) add_library(${DOLPHIN_EXE} SHARED ${SRCS} ${ANDROID_SRCS})
target_link_libraries(${DOLPHIN_EXE} target_link_libraries(${DOLPHIN_EXE}
log log
android android
@ -180,8 +173,10 @@ if(ANDROID)
add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD
COMMAND cp ARGS -r ${CMAKE_SOURCE_DIR}/Data/Sys/Shaders ${CMAKE_SOURCE_DIR}/Source/Android/assets/ COMMAND cp ARGS -r ${CMAKE_SOURCE_DIR}/Data/Sys/Shaders ${CMAKE_SOURCE_DIR}/Source/Android/assets/
) )
else()
add_executable(${DOLPHIN_EXE} ${SRCS}) set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} ${DOLPHIN_EXE})
elseif(wxWidgets_FOUND)
add_executable(${DOLPHIN_EXE} ${SRCS} ${GUI_SRCS})
target_link_libraries(${DOLPHIN_EXE} ${LIBS} ${WXLIBS}) target_link_libraries(${DOLPHIN_EXE} ${LIBS} ${WXLIBS})
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include(BundleUtilities) include(BundleUtilities)
@ -268,6 +263,13 @@ else()
else() else()
install(TARGETS ${DOLPHIN_EXE} RUNTIME DESTINATION ${bindir}) install(TARGETS ${DOLPHIN_EXE} RUNTIME DESTINATION ${bindir})
endif() endif()
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} ${DOLPHIN_EXE})
endif() endif()
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} ${DOLPHIN_EXE}) if(USE_X11)
set(DOLPHIN_NOGUI_EXE ${DOLPHIN_EXE_BASE}-nogui)
add_executable(${DOLPHIN_NOGUI_EXE} ${SRCS} ${NOGUI_SRCS})
target_link_libraries(${DOLPHIN_NOGUI_EXE} ${LIBS})
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} ${DOLPHIN_NOGUI_EXE})
endif()

View File

@ -175,7 +175,10 @@ static wxArrayString GetListOfResolutions()
ZeroMemory(&dmi, sizeof(dmi)); ZeroMemory(&dmi, sizeof(dmi));
} }
#elif defined(HAVE_XRANDR) && HAVE_XRANDR #elif defined(HAVE_XRANDR) && HAVE_XRANDR
main_frame->m_XRRConfig->AddResolutions(retlist); std::vector<std::string> resos;
main_frame->m_XRRConfig->AddResolutions(resos);
for (auto res : resos)
retlist.Add(StrToWxStr(res));
#elif defined(__APPLE__) #elif defined(__APPLE__)
CFArrayRef modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), nullptr); CFArrayRef modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), nullptr);
for (CFIndex i = 0; i < CFArrayGetCount(modes); i++) for (CFIndex i = 0; i < CFArrayGetCount(modes); i++)

View File

@ -254,8 +254,7 @@ void XRRConfiguration::ToggleDisplayMode(bool bFullscreen)
XSync(dpy, false); XSync(dpy, false);
} }
#if defined(HAVE_WX) && HAVE_WX void XRRConfiguration::AddResolutions(std::vector<std::string>& resos)
void XRRConfiguration::AddResolutions(wxArrayString& arrayStringFor_FullscreenResolution)
{ {
if (!bValid || !screenResources) if (!bValid || !screenResources)
return; return;
@ -268,7 +267,6 @@ void XRRConfiguration::AddResolutions(wxArrayString& arrayStringFor_FullscreenRe
if (output_info && output_info->crtc && output_info->connection == RR_Connected) if (output_info && output_info->crtc && output_info->connection == RR_Connected)
{ {
std::vector<std::string> resos;
for (int j = 0; j < output_info->nmode; j++) for (int j = 0; j < output_info->nmode; j++)
for (int k = 0; k < screenResources->nmode; k++) for (int k = 0; k < screenResources->nmode; k++)
if (output_info->modes[j] == screenResources->modes[k].id) if (output_info->modes[j] == screenResources->modes[k].id)
@ -280,7 +278,6 @@ void XRRConfiguration::AddResolutions(wxArrayString& arrayStringFor_FullscreenRe
if (std::find(resos.begin(), resos.end(), strRes) == resos.end()) if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
{ {
resos.push_back(strRes); resos.push_back(strRes);
arrayStringFor_FullscreenResolution.Add(StrToWxStr(strRes));
} }
} }
} }
@ -288,7 +285,6 @@ void XRRConfiguration::AddResolutions(wxArrayString& arrayStringFor_FullscreenRe
XRRFreeOutputInfo(output_info); XRRFreeOutputInfo(output_info);
} }
} }
#endif
#endif #endif

View File

@ -51,9 +51,7 @@ class XRRConfiguration
void Update(); void Update();
void ToggleDisplayMode(bool bFullscreen); void ToggleDisplayMode(bool bFullscreen);
#if defined(HAVE_WX) && HAVE_WX void AddResolutions(std::vector<std::string>& resos);
void AddResolutions(wxArrayString& arrayStringFor_FullscreenResolution);
#endif
private: private:
Display *dpy; Display *dpy;