diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2016-03-02 00:54:37 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2016-03-02 00:54:37 +0000 |
| commit | 53859c584f203b11b9a3a9cd5600e938421f2f36 (patch) | |
| tree | fb27aaa0195f5aca5cdc436e43fbb0b81f8de3d8 | |
| parent | f14de4048eb36ce1aa07d837349dc9687f6f0a61 (diff) | |
Add support for SDL as a base library on OS X.
This commit adds the basic setup in CMake to allow SDL as a base
library for FLTK on OS X (and probably for other platforms as well).
The SDL library driver set is derived from yet another new driver
set named 'Pico'. 'Pico' is a base class for a driver that will
allow porting of FLTK with the tinyest amount of effort. This
implementation of the SDL driver shall be documented very well
to explain the porting process.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11262 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
36 files changed, 399 insertions, 14 deletions
diff --git a/CMake/FindSDL2.cmake b/CMake/FindSDL2.cmake new file mode 100644 index 000000000..026dc34e7 --- /dev/null +++ b/CMake/FindSDL2.cmake @@ -0,0 +1,169 @@ + +# This module defines +# SDL2_LIBRARY, the name of the library to link against +# SDL2_FOUND, if false, do not try to link to SDL2 +# SDL2_INCLUDE_DIR, where to find SDL.h +# +# This module responds to the the flag: +# SDL2_BUILDING_LIBRARY +# If this is defined, then no SDL2main will be linked in because +# only applications need main(). +# Otherwise, it is assumed you are building an application and this +# module will attempt to locate and set the the proper link flags +# as part of the returned SDL2_LIBRARY variable. +# +# Don't forget to include SDLmain.h and SDLmain.m your project for the +# OS X framework based version. (Other versions link to -lSDL2main which +# this module will try to find on your behalf.) Also for OS X, this +# module will automatically add the -framework Cocoa on your behalf. +# +# +# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration +# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library +# (SDL2.dll, libsdl2.so, SDL2.framework, etc). +# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again. +# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value +# as appropriate. These values are used to generate the final SDL2_LIBRARY +# variable, but when these values are unset, SDL2_LIBRARY does not get created. +# +# +# $SDL2DIR is an environment variable that would +# correspond to the ./configure --prefix=$SDL2DIR +# used in building SDL2. +# l.e.galup 9-20-02 +# +# Modified by Eric Wing. +# Added code to assist with automated building by using environmental variables +# and providing a more controlled/consistent search behavior. +# Added new modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). +# Also corrected the header search path to follow "proper" SDL guidelines. +# Added a search for SDL2main which is needed by some platforms. +# Added a search for threads which is needed by some platforms. +# Added needed compile switches for MinGW. +# +# On OSX, this will prefer the Framework version (if found) over others. +# People will have to manually change the cache values of +# SDL2_LIBRARY to override this selection or set the CMake environment +# CMAKE_INCLUDE_PATH to modify the search paths. +# +# Note that the header path has changed from SDL2/SDL.h to just SDL.h +# This needed to change because "proper" SDL convention +# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability +# reasons because not all systems place things in SDL2/ (see FreeBSD). + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +message("<FindSDL2.cmake>") + +SET(SDL2_SEARCH_PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ${SDL2_PATH} +) + +FIND_PATH(SDL2_INCLUDE_DIR SDL.h + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES include/SDL2 include + PATHS ${SDL2_SEARCH_PATHS} +) + +FIND_LIBRARY(SDL2_LIBRARY_TEMP + NAMES SDL2 + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES lib64 lib + PATHS ${SDL2_SEARCH_PATHS} +) + +IF(NOT SDL2_BUILDING_LIBRARY) + IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") + # Non-OS X framework versions expect you to also dynamically link to + # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms + # seem to provide SDL2main for compatibility even though they don't + # necessarily need it. + FIND_LIBRARY(SDL2MAIN_LIBRARY + NAMES SDL2main + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES lib64 lib + PATHS ${SDL2_SEARCH_PATHS} + ) + ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") +ENDIF(NOT SDL2_BUILDING_LIBRARY) + +# SDL2 may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +IF(NOT APPLE) + FIND_PACKAGE(Threads) +ENDIF(NOT APPLE) + +# MinGW needs an additional library, mwindows +# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows +# (Actually on second look, I think it only needs one of the m* libraries.) +IF(MINGW) + SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") +ENDIF(MINGW) + +IF(SDL2_LIBRARY_TEMP) + # For SDL2main + IF(NOT SDL2_BUILDING_LIBRARY) + IF(SDL2MAIN_LIBRARY) + SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(SDL2MAIN_LIBRARY) + ENDIF(NOT SDL2_BUILDING_LIBRARY) + + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a pre-used variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + IF(APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa") + ENDIF(APPLE) + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + IF(NOT APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(NOT APPLE) + + # For MinGW library + IF(MINGW) + SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(MINGW) + + # Set the final string here so the GUI reflects the final state. + SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found") + # Set the temp variable to INTERNAL so it is not seen in the CMake GUI + SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") +ENDIF(SDL2_LIBRARY_TEMP) + +message("</FindSDL2.cmake>") + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) + diff --git a/CMake/macros.cmake b/CMake/macros.cmake index 2d2b1cc04..56ab6ab69 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -119,7 +119,7 @@ macro(CREATE_EXAMPLE NAME SOURCES LIBRARIES) FLTK_RUN_FLUID(FLUID_SOURCES "${flsrcs}") endif(flsrcs) - if(APPLE AND NOT OPTION_APPLE_X11) + if(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) unset(RESOURCE_PATH) if(${tname} STREQUAL "blocks" OR ${tname} STREQUAL "checkers" OR ${tname} STREQUAL "sudoku") set( ICON_NAME ${tname}.icns ) @@ -138,7 +138,7 @@ macro(CREATE_EXAMPLE NAME SOURCES LIBRARIES) endif(DEFINED RESOURCE_PATH) else() add_executable(${tname} WIN32 ${srcs} ${FLUID_SOURCES}) - endif(APPLE AND NOT OPTION_APPLE_X11) + endif(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) set_target_properties(${tname} PROPERTIES OUTPUT_NAME ${oname} @@ -149,9 +149,9 @@ macro(CREATE_EXAMPLE NAME SOURCES LIBRARIES) endif(NOT ${tname} STREQUAL "demo") set_target_properties(${tname} PROPERTIES RESOURCE ${RESOURCE_PATH}) endif(APPLE AND DEFINED RESOURCE_PATH) - if(APPLE AND (NOT OPTION_APPLE_X11) AND ${tname} STREQUAL "editor") + if(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL) AND ${tname} STREQUAL "editor") set_target_properties("editor" PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/test/editor-Info.plist" ) - endif(APPLE AND (NOT OPTION_APPLE_X11) AND ${tname} STREQUAL "editor") + endif(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL) AND ${tname} STREQUAL "editor") target_link_libraries(${tname} ${LIBRARIES}) diff --git a/CMake/options.cmake b/CMake/options.cmake index 750b9bc25..cf86c6f2b 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -50,6 +50,7 @@ endif(UNIX) ####################################################################### if(APPLE) option(OPTION_APPLE_X11 "use X11" OFF) + option(OPTION_APPLE_SDL "use SDL" OFF) endif(APPLE) if((NOT APPLE OR OPTION_APPLE_X11) AND NOT WIN32) @@ -63,6 +64,15 @@ if((NOT APPLE OR OPTION_APPLE_X11) AND NOT WIN32) endif(X11_FOUND) endif((NOT APPLE OR OPTION_APPLE_X11) AND NOT WIN32) +if (OPTION_APPLE_SDL) + find_package(SDL2 REQUIRED) + if (SDL2_FOUND) + set(USE_SDL 1) + set(FL_PORTING 1) + list(APPEND FLTK_LDLIBS SDL2_LIBRARIES) + endif(SDL2_FOUND) +endif(OPTION_APPLE_SDL) + ####################################################################### option(OPTION_USE_POLL "use poll if available" OFF) @@ -134,6 +144,8 @@ if(OPTION_USE_GL) set(OPENGL_FOUND TRUE) get_filename_component(PATH_TO_XLIBS ${X11_X11_LIB} PATH) set(OPENGL_LIBRARIES -L${PATH_TO_XLIBS} -lGLU -lGL) + elseif(OPTION_APPLE_SDL) + set(OPENGL_FOUND FALSE) else() include(FindOpenGL) endif(OPTION_APPLE_X11) diff --git a/CMake/setup.cmake b/CMake/setup.cmake index b2d0142f6..a746e89c7 100644 --- a/CMake/setup.cmake +++ b/CMake/setup.cmake @@ -99,6 +99,9 @@ if(APPLE) if(OPTION_APPLE_X11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U__APPLE__") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U__APPLE__") + elseif(OPTION_APPLE_SDL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SDL2_INCLUDE_DIRS} -U__APPLE__ -DFL_PORTING") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SDL2_INCLUDE_DIRS} -U__APPLE__ -DFL_PORTING") else() set(__APPLE_QUARTZ__ 1) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa") @@ -205,7 +205,7 @@ public: // should be private! #elif defined(WIN32) // not needed in WIN32 #elif defined(FL_PORTING) -# pragma message "FL_PORTING: define a type for FL_SOCKET" +# pragma message "FL_PORTING: add these functions to all platforms?" // no default implementation #else // not needed in X11 diff --git a/FL/fl_utf8.h b/FL/fl_utf8.h index 306cf3c58..c4b3d6ec3 100644 --- a/FL/fl_utf8.h +++ b/FL/fl_utf8.h @@ -63,6 +63,7 @@ #elif defined(FL_PORTING) # pragma message "FL_PORTING: include utf8 support files and define utf8 types" # define xchar unsigned short +// TODO: the condition below is not portable! #else /* X11 */ # include <sys/types.h> # include <sys/stat.h> diff --git a/FL/porting.H b/FL/porting.H index 6c3d7cfc9..ec3029049 100644 --- a/FL/porting.H +++ b/FL/porting.H @@ -78,7 +78,7 @@ public: int wait_for_expose; // NSCursor *cursor; static Fl_X* first; - static Fl_X* i(const Fl_Window* w) {return w->i;} + static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;} static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&); static Fl_X* make(Fl_Window*); void flush(); @@ -155,6 +155,98 @@ extern void fl_end_offscreen(); extern int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); extern void fl_open_display(); +/* + + The following symbols are not found if we naively compile the core modules and + no specific platform implementations. This list is a hint at all the functions + and methods that probably need to be refactored into the driver system. + + Undefined symbols for architecture x86_64: + "fl_set_spot(int, int, int, int, int, int, Fl_Window*)", referenced from: + Fl_Input_::drawtext(int, int, int, int) in libfltkd.a(Fl_Input_.o) + Fl_Input_::handletext(int, int, int, int, int) in libfltkd.a(Fl_Input_.o) + "fl_reset_spot()", referenced from: + Fl_Input_::handletext(int, int, int, int, int) in libfltkd.a(Fl_Input_.o) + "fl_filename_name(char const*)", referenced from: + Fl_Window::show(int, char**) in libfltkd.a(Fl_arg.o) + "fl_clipboard_notify_change()", referenced from: + Fl::add_clipboard_notify(void (*)(int, void*), void*) in libfltkd.a(Fl.o) + Fl::remove_clipboard_notify(void (*)(int, void*)) in libfltkd.a(Fl.o) + "Fl_Screen_Driver::newScreenDriver()", referenced from: + Fl::screen_driver() in libfltkd.a(Fl.o) + "Fl_Graphics_Driver::newMainGraphicsDriver()", referenced from: + Fl_Display_Device::display_device() in libfltkd.a(Fl_Device.o) + "Fl_Graphics_Driver::global_gc()", referenced from: + Fl_Surface_Device::set_current() in libfltkd.a(Fl_Device.o) + "Fl::dnd()", referenced from: + Fl_Input::handle(int) in libfltkd.a(Fl_Input.o) + "Fl::copy(char const*, int, int, char const*)", referenced from: + Fl::selection(Fl_Widget&, char const*, int) in libfltkd.a(Fl.o) + Fl_Input_::copy(int) in libfltkd.a(Fl_Input_.o) + Fl_Input_::copy_cuts() in libfltkd.a(Fl_Input_.o) + "Fl::paste(Fl_Widget&, int, char const*)", referenced from: + Fl::paste(Fl_Widget&) in libfltkd.a(Fl.o) + Fl_Input::kf_paste() in libfltkd.a(Fl_Input.o) + Fl_Input::handle(int) in libfltkd.a(Fl_Input.o) + "Fl::get_mouse(int&, int&)", referenced from: + Fl_Screen_Driver::screen_xywh(int&, int&, int&, int&) in libfltkd.a(Fl_Screen_Driver.o) + Fl_Screen_Driver::screen_work_area(int&, int&, int&, int&) in libfltkd.a(Fl_Screen_Driver.o) + Fl_Window::hotspot(int, int, int) in libfltkd.a(Fl_Window_hotspot.o) + "Fl::set_color(unsigned int, unsigned int)", referenced from: + Fl::set_color(unsigned int, unsigned char, unsigned char, unsigned char) in libfltkd.a(fl_color.o) + Fl::background2(unsigned char, unsigned char, unsigned char) in libfltkd.a(Fl_get_system_colors.o) + "Fl_X::set_cursor(Fl_Cursor)", referenced from: + Fl_Window::cursor(Fl_Cursor) in libfltkd.a(fl_cursor.o) + "Fl_X::set_cursor(Fl_RGB_Image const*, int, int)", referenced from: + Fl_Window::cursor(Fl_RGB_Image const*, int, int) in libfltkd.a(fl_cursor.o) + "Fl_X::set_default_icons(Fl_RGB_Image const**, int)", referenced from: + Fl_Window::default_icons(Fl_RGB_Image const**, int) in libfltkd.a(Fl_Window.o) + "Fl_X::flush()", referenced from: + Fl::flush() in libfltkd.a(Fl.o) + "Fl_X::set_icons()", referenced from: + Fl_Window::icons(Fl_RGB_Image const**, int) in libfltkd.a(Fl_Window.o) + "Fl_Window::size_range_()", referenced from: + Fl_Window::size_range(int, int, int, int, int, int, int) in libfltkd.a(fl_ask.o) + "Fl_Window::fullscreen_x()", referenced from: + Fl_Window::fullscreen() in libfltkd.a(Fl_Window_fullscreen.o) + Fl_Window::fullscreen_screens(int, int, int, int) in libfltkd.a(Fl_Window_fullscreen.o) + "Fl_Window::make_current()", referenced from: + Fl_Window::flush() in libfltkd.a(Fl.o) + Fl_Double_Window::flush(int) in libfltkd.a(Fl_Double_Window.o) + traverse_to_gl_subwindows(Fl_Group*, unsigned char*, int, int, int, int, int, Fl_RGB_Image*) in libfltkd.a(fl_read_image.o) + Fl_Widget_Surface::print_window_part(Fl_Window*, int, int, int, int, int, int) in libfltkd.a(Fl_Widget_Surface.o) + "Fl_Window::fullscreen_off_x(int, int, int, int)", referenced from: + Fl_Window::fullscreen_off(int, int, int, int) in libfltkd.a(Fl_Window_fullscreen.o) + "Fl_Window::show()", referenced from: + vtable for Fl_Window in libfltkd.a(Fl_Window_shape.o) + Fl_Double_Window::show() in libfltkd.a(Fl_Double_Window.o) + Fl_Single_Window::show() in libfltkd.a(Fl_Single_Window.o) + "Fl_Window::label(char const*, char const*)", referenced from: + Fl_Window::label(char const*) in libfltkd.a(Fl_Window.o) + Fl_Window::copy_label(char const*) in libfltkd.a(Fl_Window.o) + Fl_Window::iconlabel(char const*) in libfltkd.a(Fl_Window.o) + "Fl_Window::resize(int, int, int, int)", referenced from: + vtable for Fl_TooltipBox in libfltkd.a(Fl_Tooltip.o) + vtable for Fl_Window in libfltkd.a(Fl_Window_shape.o) + vtable for Fl_Menu_Window in libfltkd.a(Fl_Menu_Window.o) + Fl_Double_Window::resize(int, int, int, int) in libfltkd.a(Fl_Double_Window.o) + vtable for menutitle in libfltkd.a(Fl_Menu.o) + vtable for menuwindow in libfltkd.a(Fl_Menu.o) + vtable for Fl_Single_Window in libfltkd.a(Fl_Single_Window.o) + ... + "Fl_Window::current_", referenced from: + Fl_Window::current() in libfltkd.a(Fl_Window.o) + "vtable for Fl_Image_Surface", referenced from: + Fl_Image_Surface::Fl_Image_Surface(int, int, int) in libfltkd.a(Fl_Image_Surface.o) + NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. + "_fl_show_iconic", referenced from: + Fl::arg(int, char**, int&) in libfltkd.a(Fl_arg.o) + "_fl_window", referenced from: + fl_read_image(unsigned char*, int, int, int, int, int) in libfltkd.a(fl_read_image.o) + Fl_Image_Surface::set_current() in libfltkd.a(Fl_Image_Surface.o) + Fl_Image_Surface::end_current() in libfltkd.a(Fl_Image_Surface.o) +*/ + // // End of "$Id$". // @@ -33,6 +33,25 @@ # include "mac.H" # elif defined(ANDROID) # pragma message "A clean port requires a driver-style system for Fl_X" +# elif defined(USE_SDL) +# pragma message "FL_PORTING: write a header file based on this file, win32.H, or mac.H to define the FLTK core internals" + +//typedef void *Window; +//typedef void *Fl_Region; +//typedef void *Fl_Bitmask; +//typedef void *Fl_Offscreen; +//#include <FL/Fl_Window.H> +//class FL_EXPORT Fl_X { +//public: +// Window xid; +// Window other_xid; +// Fl_X *next; +// char wait_for_expose; +// static Fl_X* first; +// static Fl_X* i(const Fl_Window* wi) {return (Fl_X*)wi->i;} +//}; + +# include "porting.H" # elif defined(FL_PORTING) # pragma message "FL_PORTING: write a header file based on this file, win32.H, or mac.H to define the FLTK core internals" # include "porting.H" diff --git a/configh.cmake.in b/configh.cmake.in index 8aaaa844e..5cd114116 100644 --- a/configh.cmake.in +++ b/configh.cmake.in @@ -160,6 +160,24 @@ #cmakedefine USE_X11 1 /* + * USE_SDL + * + * Should we use SDL for the current platform + * + */ + +#cmakedefine USE_SDL 1 + +/* + * FL_PORTING + * + * A little helper that points to locations in the core that still need to be ported to + * the core driver setup. + */ + +#cmakedefine FL_PORTING 0 + +/* * HAVE_OVERLAY: * * Use the X overlay extension? FLTK will try to use an overlay diff --git a/fluid/CMakeLists.txt b/fluid/CMakeLists.txt index 87931114c..6852afbed 100644 --- a/fluid/CMakeLists.txt +++ b/fluid/CMakeLists.txt @@ -38,13 +38,13 @@ set(CPPFILES widget_panel.cxx ) -if(APPLE AND NOT OPTION_APPLE_X11) +if(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) set( ICON_NAME fluid.icns ) set( ICON_PATH "${PROJECT_SOURCE_DIR}/fluid/Fluid.app/Contents/Resources/${ICON_NAME}" ) add_executable(fluid MACOSX_BUNDLE ${CPPFILES} ${ICON_PATH}) else() add_executable(fluid ${CPPFILES}) -endif(APPLE AND NOT OPTION_APPLE_X11) +endif(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) target_link_libraries(fluid fltk fltk_images fltk_forms) @@ -61,7 +61,7 @@ if(HAVE_XRENDER) target_link_libraries(fluid ${X11_Xrender_LIB}) endif(HAVE_XRENDER) -if(APPLE AND NOT OPTION_APPLE_X11) +if(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) set_target_properties(fluid PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) set_target_properties(fluid PROPERTIES RESOURCE ${ICON_PATH}) install(TARGETS fluid DESTINATION ${FLTK_BINDIR}) @@ -72,7 +72,7 @@ else() LIBRARY DESTINATION ${FLTK_LIBDIR} ARCHIVE DESTINATION ${FLTK_LIBDIR} ) -endif(APPLE AND NOT OPTION_APPLE_X11) +endif(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) if(UNIX) install(FILES fluid.desktop diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c5f60b019..de548cf13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -152,7 +152,7 @@ file(GLOB "../FL/*.h" ) -if (USE_X11 AND NOT OPTION_PRINT_SUPPORT) +if ((USE_X11 OR USE_SDL) AND NOT OPTION_PRINT_SUPPORT) set(PSFILES ) else() @@ -160,7 +160,7 @@ else() drivers/PostScript/Fl_PostScript.cxx drivers/PostScript/Fl_PostScript_image.cxx ) -endif(USE_X11 AND NOT OPTION_PRINT_SUPPORT) +endif((USE_X11 OR USE_SDL) AND NOT OPTION_PRINT_SUPPORT) set(DRIVER_FILES) @@ -199,6 +199,35 @@ if (USE_X11) drivers/Xlib/Fl_Xlib_Copy_Surface.H ) +elseif (USE_SDL) + + # SDL2 + + set(DRIVER_FILES + drivers/Pico/Fl_Pico_System_Driver.cxx + drivers/Pico/Fl_Pico_Screen_Driver.cxx + drivers/Pico/Fl_Pico_Window_Driver.cxx + drivers/Pico/Fl_Pico_Graphics_Driver.cxx + drivers/Pico/Fl_Pico_Copy_Surface.cxx + drivers/SDL/Fl_SDL_System_Driver.cxx + drivers/SDL/Fl_SDL_Screen_Driver.cxx + drivers/SDL/Fl_SDL_Window_Driver.cxx + drivers/SDL/Fl_SDL_Graphics_Driver.cxx + drivers/SDL/Fl_SDL_Copy_Surface.cxx + ) + set(DRIVER_HEADER_FILES + drivers/Pico/Fl_Pico_System_Driver.H + drivers/Pico/Fl_Pico_Screen_Driver.H + drivers/Pico/Fl_Pico_Window_Driver.H + drivers/Pico/Fl_Pico_Graphics_Driver.H + drivers/Pico/Fl_Pico_Copy_Surface.H + drivers/SDL/Fl_SDL_System_Driver.H + drivers/SDL/Fl_SDL_Screen_Driver.H + drivers/SDL/Fl_SDL_Window_Driver.H + drivers/SDL/Fl_SDL_Graphics_Driver.H + drivers/SDL/Fl_SDL_Copy_Surface.H + ) + elseif (APPLE) # Apple Quartz @@ -340,7 +369,7 @@ set(CFILES add_definitions(-DFL_LIBRARY) -if(APPLE AND NOT OPTION_APPLE_X11) +if(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) set(MMFILES Fl_cocoa.mm Fl_Quartz_Printer.mm @@ -350,7 +379,7 @@ if(APPLE AND NOT OPTION_APPLE_X11) else() set(MMFILES ) -endif(APPLE AND NOT OPTION_APPLE_X11) +endif(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) ####################################################################### FL_ADD_LIBRARY(fltk STATIC "${CPPFILES};${PSFILES};${MMFILES};${CFILES};fl_call_main.c;${HEADER_FILES};${DRIVER_HEADER_FILES}") @@ -367,6 +396,10 @@ if(USE_X11) target_link_libraries(fltk ${X11_LIBRARIES}) endif(USE_X11) +if (USE_SDL) + target_link_libraries(fltk ${SDL2_LIBRARIES}) +endif(USE_SDL) + if(WIN32) target_link_libraries(fltk comctl32) endif(WIN32) @@ -446,6 +479,10 @@ if(USE_X11) target_link_libraries(fltk_SHARED ${X11_LIBRARIES}) endif(USE_X11) +if (USE_SDL) + target_link_libraries(fltk ${SDL2_LIBRARIES}) +endif(USE_SDL) + if(WIN32) target_link_libraries(fltk_SHARED comctl32) endif(WIN32) diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx index 5e3b881f1..4831ac197 100644 --- a/src/Fl_Image_Surface.cxx +++ b/src/Fl_Image_Surface.cxx @@ -221,6 +221,8 @@ void Fl_Image_Surface::untranslate() { ((Fl_Translated_GDI_Graphics_Driver*)driver())->untranslate_all(); } +#elif defined(USE_SDL) + #else void Fl_Image_Surface::translate(int x, int y) { diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index cb87b9ee9..36c5cf9e1 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -16,6 +16,8 @@ // http://www.fltk.org/str.php // +#include "config.h" + // make this available on all platforms to make code maintainability easier class Fl_Widget *fl_selection_requestor; @@ -25,6 +27,8 @@ class Fl_Widget *fl_selection_requestor; // PORTME: Fl_Screen_Driver // PORTME: Fl_Window_Driver //# include "Fl_mac.cxx" // now Fl_cocoa.mm +#elif defined(USE_SDL) +# pragma message "FL_SDL: implement the FLTK core in its own file" #elif defined(FL_PORTING) # pragma message "FL_PORTING: implement the FLTK core in its own file" # include "Fl_porting.cxx" diff --git a/src/drivers/Pico/Fl_Pico_Copy_Surface.H b/src/drivers/Pico/Fl_Pico_Copy_Surface.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_Copy_Surface.H @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_Copy_Surface.cxx b/src/drivers/Pico/Fl_Pico_Copy_Surface.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_Copy_Surface.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_Graphics_Driver.H b/src/drivers/Pico/Fl_Pico_Graphics_Driver.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_Graphics_Driver.H @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx b/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_Screen_Driver.H b/src/drivers/Pico/Fl_Pico_Screen_Driver.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_Screen_Driver.H @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_Screen_Driver.cxx b/src/drivers/Pico/Fl_Pico_Screen_Driver.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_Screen_Driver.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_System_Driver.H b/src/drivers/Pico/Fl_Pico_System_Driver.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_System_Driver.H @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_System_Driver.cxx b/src/drivers/Pico/Fl_Pico_System_Driver.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_System_Driver.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_Window_Driver.H b/src/drivers/Pico/Fl_Pico_Window_Driver.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_Window_Driver.H @@ -0,0 +1 @@ + diff --git a/src/drivers/Pico/Fl_Pico_Window_Driver.cxx b/src/drivers/Pico/Fl_Pico_Window_Driver.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/Pico/Fl_Pico_Window_Driver.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_Copy_Surface.H b/src/drivers/SDL/Fl_SDL_Copy_Surface.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_Copy_Surface.H @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_Copy_Surface.cxx b/src/drivers/SDL/Fl_SDL_Copy_Surface.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_Copy_Surface.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_Graphics_Driver.H b/src/drivers/SDL/Fl_SDL_Graphics_Driver.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_Graphics_Driver.H @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_Graphics_Driver.cxx b/src/drivers/SDL/Fl_SDL_Graphics_Driver.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_Graphics_Driver.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_Screen_Driver.H b/src/drivers/SDL/Fl_SDL_Screen_Driver.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_Screen_Driver.H @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_Screen_Driver.cxx b/src/drivers/SDL/Fl_SDL_Screen_Driver.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_Screen_Driver.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_System_Driver.H b/src/drivers/SDL/Fl_SDL_System_Driver.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_System_Driver.H @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_System_Driver.cxx b/src/drivers/SDL/Fl_SDL_System_Driver.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_System_Driver.cxx @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_Window_Driver.H b/src/drivers/SDL/Fl_SDL_Window_Driver.H new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_Window_Driver.H @@ -0,0 +1 @@ + diff --git a/src/drivers/SDL/Fl_SDL_Window_Driver.cxx b/src/drivers/SDL/Fl_SDL_Window_Driver.cxx new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/drivers/SDL/Fl_SDL_Window_Driver.cxx @@ -0,0 +1 @@ + diff --git a/src/xutf8/utf8Utils.c b/src/xutf8/utf8Utils.c index 41343f459..9be6f8607 100644 --- a/src/xutf8/utf8Utils.c +++ b/src/xutf8/utf8Utils.c @@ -14,6 +14,8 @@ * http://www.fltk.org/str.php */ +#include <config.h> + #if defined(WIN32) || defined(__APPLE__) /* PORTME: Fl_Screen_Driver - platform unicode */ #elif defined(FL_PORTING) # pragma message "FL_PORTING: utf8" diff --git a/src/xutf8/utf8Wrap.c b/src/xutf8/utf8Wrap.c index 27e048cfe..d7321b289 100644 --- a/src/xutf8/utf8Wrap.c +++ b/src/xutf8/utf8Wrap.c @@ -14,6 +14,8 @@ * http://www.fltk.org/str.php */ +#include <config.h> + #if defined(WIN32) || defined(__APPLE__) /* PORTME: Fl_Screen_Driver - platform unicode */ #elif defined(FL_PORTING) # pragma message "FL_PORTING: utf8" diff --git a/test/list_visuals.cxx b/test/list_visuals.cxx index 42bc36f38..dca7de222 100644 --- a/test/list_visuals.cxx +++ b/test/list_visuals.cxx @@ -33,6 +33,10 @@ int main(int, char**) { return 1; } +#elif defined(FL_PORTING) + +# pragma message "FL_PORTING: list_visuals" + #else #include <config.h> |
