CMake: Remove obsolete USE_X11 option and add USE_WIN32_WINDOWS

USE_WIN32_WINDOWS was previously defined in PlatformAbstraction.h. Move it
to CMakeLists.txt and config.h like its peers. Replace USE_X11 with USE_GTK
or GDK_WINDOWING_X11 as appropriate.
objectmenu
Günther Brammer 2016-01-22 17:50:00 +01:00
parent 11bbeb2a5b
commit 93f12150c4
12 changed files with 41 additions and 60 deletions

View File

@ -32,11 +32,10 @@ list(APPEND CMAKE_PREFIX_PATH ${CMAKE_ADDITIONAL_DEPS_PATH})
############################################################################
include(CMakeDependentOption)
option(PROJECT_FOLDERS "Put source files into subfolders in project file" ON)
option(USE_SDL_MAINLOOP "Use SDL to create windows etc." OFF)
CMAKE_DEPENDENT_OPTION(USE_X11 "Use X11 to create windows etc." ON
"UNIX AND NOT APPLE AND NOT USE_SDL_MAINLOOP" OFF)
CMAKE_DEPENDENT_OPTION(USE_GTK "Use GTK for the developer mode" ON "USE_X11" OFF)
CMAKE_DEPENDENT_OPTION(USE_COCOA "Use Apple Cocoa for the developer mode and the windows." ON "APPLE" OFF)
CMAKE_DEPENDENT_OPTION(USE_COCOA "Use Apple Cocoa widgets." ON "APPLE" OFF)
CMAKE_DEPENDENT_OPTION(USE_WIN32_WINDOWS "Use Microsoft Desktop App User Interface widgets." ON "WIN32" OFF)
CMAKE_DEPENDENT_OPTION(USE_GTK "Use GTK+ widgets." ON "NOT USE_COCOA AND NOT USE_WIN32_WINDOWS" OFF)
CMAKE_DEPENDENT_OPTION(USE_SDL_MAINLOOP "Use SDL to create windows etc. No editor." ON "NOT USE_COCOA AND NOT USE_WIN32_WINDOWS AND NOT USE_GTK" OFF)
option(WITH_AUTOMATIC_UPDATE "Automatic updates are downloaded from the project website." OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ${PROJECT_FOLDERS})
@ -263,7 +262,7 @@ add_definitions(${GLEW_DEFINITIONS})
set(CMAKE_REQUIRED_INCLUDES "${GLEW_INCLUDE_DIRS}")
CHECK_CXX_SOURCE_COMPILES("#include <GL/glew.h>\nvoid GLAPIENTRY OpenGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, const void* userParam) {}\nint main() { GLDEBUGPROCARB proc = &OpenGLDebugProc; }" GLDEBUGPROCARB_USERPARAM_IS_CONST)
if(USE_X11)
if(USE_GTK AND UNIX)
FINDLIB(X11_LIBRARIES X11)
FINDLIB(XRANDR_LIBRARIES Xrandr)
endif()
@ -904,7 +903,7 @@ elseif(USE_SDL_MAINLOOP)
src/platform/C4AppSDL.cpp
src/platform/C4WindowSDL.cpp
)
elseif(WIN32)
elseif(USE_WIN32_WINDOWS)
list(APPEND OC_GUI_SOURCES
src/editor/C4ConsoleWin32.cpp
src/platform/C4WindowWin32.cpp

View File

@ -89,19 +89,6 @@
/* MP3 music */
#cmakedefine USE_MP3 1
/* Define to 1 if SDL is used for the main loop */
#cmakedefine USE_SDL_MAINLOOP 1
/* Define to 1 if the X Window System is used */
#cmakedefine USE_X11 1
#cmakedefine USE_GTK 1
/* Use Apple Cocoa for the UI */
#cmakedefine USE_COCOA 1
/* Enable automatic update system */
#cmakedefine WITH_AUTOMATIC_UPDATE 1
/* Define to 1 if the userParam parameter to GLDEBUGPROCARB is const, as the
spec requires. */
#cmakedefine GLDEBUGPROCARB_USERPARAM_IS_CONST 1
@ -115,24 +102,25 @@
/* Define to 1 if you have support for precompiled headers */
#cmakedefine HAVE_PRECOMPILED_HEADERS 1
#ifndef USE_CONSOLE
/* The widgets for the windows and the editor GUI */
#cmakedefine USE_SDL_MAINLOOP 1
#cmakedefine USE_WIN32_WINDOWS 1
#cmakedefine USE_COCOA 1
#cmakedefine USE_GTK 1
/* Enable automatic update system */
#cmakedefine WITH_AUTOMATIC_UPDATE 1
/* Select an audio provider */
#define AUDIO_TK AUDIO_TK_${Audio_TK_UPPER}
#else
#define AUDIO_TK AUDIO_TK_NONE
#endif
#define AUDIO_TK_NONE 0
#define AUDIO_TK_OPENAL 1
#define AUDIO_TK_SDL_MIXER 3
#define AUDIO_TK AUDIO_TK_${Audio_TK_UPPER}
/* Include OpenAL extensions (alext.h) for sound modifiers */
#cmakedefine HAVE_ALEXT 1
#ifdef USE_CONSOLE
/* FIXME: Sort this out in CMake instead of here */
#undef USE_COCOA
#undef USE_SDL_MAINLOOP
#undef USE_X11
#undef USE_GTK 1
#undef WITH_AUTOMATIC_UPDATE
#undef AUDIO_TK
#define AUDIO_TK AUDIO_TK_NONE
#endif

View File

@ -1873,7 +1873,7 @@ bool C4Game::SaveGameTitle(C4Group &hGroup)
bool C4Game::DoKeyboardInput(C4KeyCode vk_code, C4KeyEventType eEventType, bool fAlt, bool fCtrl, bool fShift, bool fRepeated, class C4GUI::Dialog *pForDialog, bool fPlrCtrlOnly, int32_t iStrength)
{
#ifdef USE_X11
#ifdef USE_GTK
static std::map<C4KeyCode, bool> PressedKeys;
// Keyrepeats are send as down, down, ..., down, up, where all downs are not distinguishable from the first.
if (eEventType == KEYEV_Down)

View File

@ -132,7 +132,7 @@ protected:
HWND hWindow; // used if pWindow==NULL
HDC hDC; // device context handle
static bool InitGlew(HINSTANCE hInst);
#elif defined(USE_X11)
#elif defined(USE_GTK)
/*GLXContext*/void * ctx;
#endif

View File

@ -439,7 +439,7 @@ bool CStdGLCtx::PageFlip()
return true;
}
#elif defined(USE_X11)
#elif defined(USE_GTK)
#include <GL/glxew.h>
#include <GL/glx.h>
#include <gtk/gtk.h>
@ -654,6 +654,6 @@ bool CStdGLCtx::PageFlip()
return true;
}
#endif //USE_X11/USE_SDL_MAINLOOP
#endif //USE_GTK/USE_SDL_MAINLOOP
#endif // USE_CONSOLE

View File

@ -22,11 +22,13 @@
#include <C4Game.h>
#include <C4Window.h>
#ifdef USE_X11
#include <gdk/gdkx.h>
#ifdef USE_GTK
#include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <X11/XKBlib.h>
#endif
#endif
#include <algorithm>
@ -100,7 +102,7 @@ struct C4KeyCodeMapEntry
const char *szShortName;
};
#if defined(USE_WIN32_WINDOWS) || defined(USE_X11)
#if defined(USE_WIN32_WINDOWS) || defined(USE_GTK)
const C4KeyCodeMapEntry KeyCodeMap[] = {
{K_ESCAPE, "Escape", "Esc"},
{K_1, "1", NULL},
@ -329,7 +331,7 @@ C4KeyCode C4KeyCodeEx::String2KeyCode(const StdStrBuf &sName)
}
}
#if defined(USE_WIN32_WINDOWS) || defined(USE_COCOA) || defined(USE_X11)
#if defined(USE_WIN32_WINDOWS) || defined(USE_COCOA) || defined(USE_GTK)
// query map
const C4KeyCodeMapEntry *pCheck = KeyCodeMap;
while (pCheck->szName) {
@ -448,7 +450,7 @@ StdStrBuf C4KeyCodeEx::KeyCode2String(C4KeyCode wCode, bool fHumanReadable, bool
if (wCode == pCheck->wCode) return StdStrBuf((pCheck->szShortName && fShort) ? pCheck->szShortName : pCheck->szName); else ++pCheck;
// not found: Compose as direct code
return FormatString("\\x%x", static_cast<unsigned int>(wCode));
#elif defined(USE_X11)
#elif defined(USE_GTK)
Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default());
KeySym keysym = (KeySym)XkbKeycodeToKeysym(dpy,wCode+8,0,0);
char* name = NULL;

View File

@ -27,7 +27,7 @@
#include <pthread.h>
#endif
#if defined(USE_X11)
#if defined(USE_GTK)
// from X.h:
//#define ShiftMask (1<<0)
//#define ControlMask (1<<2)
@ -148,7 +148,7 @@ public:
pthread_t MainThread;
#endif
#if defined(USE_X11)
#if defined(USE_GTK)
protected:
class C4X11AppImpl * Priv;

View File

@ -28,7 +28,7 @@
#include <glib.h>
#include <gtk/gtk.h>
#ifdef USE_X11
#ifdef GDK_WINDOWING_X11
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <gdk/gdkx.h>

View File

@ -21,7 +21,7 @@
#include <StdBuf.h>
#if defined(USE_WIN32_WINDOWS) || defined(USE_X11) || defined(USE_CONSOLE)
#if defined(USE_WIN32_WINDOWS) || defined(USE_GTK) || defined(USE_CONSOLE)
#define K_ESCAPE 1
#define K_1 2
#define K_2 3
@ -274,10 +274,8 @@ extern C4KeyCode K_X;
extern C4KeyCode K_A;
#endif
#ifdef USE_X11
// Forward declarations because xlib.h is evil
typedef union _XEvent XEvent;
typedef struct _XDisplay Display;
#ifdef USE_GTK
// Forward declaration because xlib.h is evil
typedef struct __GLXFBConfigRec *GLXFBConfig;
#endif
@ -334,14 +332,12 @@ public:
HWND hWindow;
HWND hRenderWindow;
virtual bool Win32DialogMessageHandling(MSG * msg) { return false; };
#elif defined(WITH_GLIB)
#elif defined(USE_GTK)
public:
/*GtkWidget*/void * window;
// Set by Init to the widget which is used as a
// render target, which can be the whole window.
/*GtkWidget*/void * render_widget;
#endif
#ifdef USE_X11
protected:
bool FindFBConfig(int samples, GLXFBConfig *info);

View File

@ -39,7 +39,7 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#ifdef USE_X11
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <GL/glx.h>

View File

@ -60,7 +60,7 @@ bool EraseItemSafe(const char *szFilename)
return false;
}
#if !defined(USE_X11)
#if !defined(USE_GTK)
bool OpenURL(char const*) {return 0;}
#endif

View File

@ -48,10 +48,6 @@
#endif
#endif
#if defined(_WIN32) && !defined(USE_CONSOLE) && !defined(USE_SDL_MAINLOOP) && !defined(USE_X11) && !defined(USE_COCOA)
#define USE_WIN32_WINDOWS
#endif
#ifdef _MSC_VER
#define DEPRECATED __declspec(deprecated)
#elif defined(__GNUC__)