[CMake] Fix Windows dll build with Visual Studio generator.
Now you can set OPTION_BUILD_SHARED_LIBS:BOOL=ON to build FLTK dll's with Visual Studio. Tested and works (Visual Studio 2010 + 2015). Note: Linux fixes included, tested and works (Ubuntu). Todo: dll names and target directories may need some changes. We really need to get rid of that "_SHARED" suffix in .so names. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11867 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
e5e7fa9b1e
commit
78d853891c
@ -1,7 +1,7 @@
|
||||
#
|
||||
# "$Id$"
|
||||
#
|
||||
# macros.cmake defines macros used by the build system
|
||||
# macros.cmake defines macros used by the CMake build system
|
||||
# Written by Michael Surette
|
||||
#
|
||||
# Copyright 1998-2016 by Bill Spitzak and others.
|
||||
@ -29,17 +29,17 @@ macro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES)
|
||||
endif (${LIBTYPE} STREQUAL "SHARED")
|
||||
|
||||
if (MSVC)
|
||||
set (LIBNAME_DEBUG "${LIBNAME}d")
|
||||
set (LIBRARY_NAME_DEBUG "${LIBRARY_NAME}d")
|
||||
else ()
|
||||
set (LIBNAME_DEBUG "${LIBNAME}")
|
||||
set (LIBRARY_NAME_DEBUG "${LIBRARY_NAME}")
|
||||
endif (MSVC)
|
||||
|
||||
add_library(${LIBRARY_NAME} ${LIBTYPE} ${LIBFILES})
|
||||
|
||||
set_target_properties(${LIBRARY_NAME}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME ${LIBNAME}
|
||||
DEBUG_OUTPUT_NAME "${LIBNAME_DEBUG}"
|
||||
OUTPUT_NAME ${LIBRARY_NAME}
|
||||
DEBUG_OUTPUT_NAME ${LIBRARY_NAME_DEBUG}
|
||||
CLEAN_DIRECT_OUTPUT TRUE
|
||||
COMPILE_DEFINITIONS "FL_LIBRARY"
|
||||
)
|
||||
@ -55,7 +55,7 @@ macro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES)
|
||||
|
||||
if (MSVC)
|
||||
if (OPTION_LARGE_FILE)
|
||||
set_target_properties(${LIBNAME}
|
||||
set_target_properties(${LIBRARYNAME}
|
||||
PROPERTIES
|
||||
LINK_FLAGS /LARGEADDRESSAWARE
|
||||
)
|
||||
|
@ -38,6 +38,15 @@ find_file(HAVE_SYS_STDTYPES_H sys/stdtypes.h)
|
||||
find_file(HAVE_X11_XREGION_H X11/Xregion.h)
|
||||
find_path(HAVE_XDBE_H Xdbe.h PATH_SUFFIXES X11/extensions extensions)
|
||||
|
||||
if (MSVC)
|
||||
message(STATUS "Note: The following three headers should all be found!")
|
||||
message(STATUS "HAVE_GL_GL_H = '${HAVE_GL_GL_H}'")
|
||||
message(STATUS "HAVE_GL_GLU_H = '${HAVE_GL_GLU_H}'")
|
||||
message(STATUS "HAVE_LOCALE_H = '${HAVE_LOCALE_H}'")
|
||||
message(STATUS "If one of these headers was not found, run cmake-gui ...")
|
||||
message(STATUS "... again from a Visual Studio developer command prompt!")
|
||||
endif (MSVC)
|
||||
|
||||
# Simulate the behavior of autoconf macro AC_HEADER_DIRENT, see:
|
||||
# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html
|
||||
# "Check for the following header files. For the first one that is found
|
||||
|
@ -74,10 +74,10 @@ class FL_EXPORT Fl_Graphics_Driver {
|
||||
friend class Fl_Pixmap;
|
||||
friend class Fl_Bitmap;
|
||||
friend class Fl_RGB_Image;
|
||||
friend int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg);
|
||||
friend void gl_start();
|
||||
friend Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array);
|
||||
friend void fl_delete_bitmask(Fl_Bitmask);
|
||||
friend FL_EXPORT int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg);
|
||||
friend FL_EXPORT void gl_start();
|
||||
friend FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array);
|
||||
friend FL_EXPORT void fl_delete_bitmask(Fl_Bitmask);
|
||||
public:
|
||||
// The following functions create the various graphics drivers that are required
|
||||
// for core operations. They must be implemented as members of Fl_Graphics_Driver,
|
||||
|
@ -64,10 +64,10 @@
|
||||
\endcode
|
||||
*/
|
||||
class FL_EXPORT Fl_Image_Surface : public Fl_Widget_Surface {
|
||||
friend Fl_Offscreen fl_create_offscreen(int w, int h);
|
||||
friend void fl_begin_offscreen(Fl_Offscreen ctx);
|
||||
friend void fl_end_offscreen(void);
|
||||
friend void fl_delete_offscreen(Fl_Offscreen ctx);
|
||||
friend FL_EXPORT Fl_Offscreen fl_create_offscreen(int w, int h);
|
||||
friend FL_EXPORT void fl_begin_offscreen(Fl_Offscreen ctx);
|
||||
friend FL_EXPORT void fl_end_offscreen(void);
|
||||
friend FL_EXPORT void fl_delete_offscreen(Fl_Offscreen ctx);
|
||||
private:
|
||||
class Fl_Image_Surface_Driver *platform_surface;
|
||||
protected:
|
||||
|
@ -45,7 +45,7 @@ extern FL_EXPORT UINT fl_wake_msg;
|
||||
extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid()
|
||||
extern FL_EXPORT int fl_background_pixel; // hack into Fl_Window::make_xid()
|
||||
extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays!
|
||||
extern FL_EXPORT void fl_release_dc(HWND w, HDC dc);
|
||||
extern void fl_release_dc(HWND w, HDC dc);
|
||||
extern FL_EXPORT void fl_save_dc( HWND w, HDC dc);
|
||||
|
||||
#endif // FL_LIBRARY || FL_INTERNALS
|
||||
|
@ -492,8 +492,7 @@ target_link_libraries(fltk_forms fltk)
|
||||
#######################################################################
|
||||
|
||||
FL_ADD_LIBRARY(fltk_images STATIC "${IMGCPPFILES}")
|
||||
target_link_libraries(fltk_images fltk ${FLTK_PNG_LIBRARIES}
|
||||
${FLTK_JPEG_LIBRARIES} ${FLTK_ZLIB_LIBRARIES})
|
||||
target_link_libraries(fltk_images fltk)
|
||||
|
||||
if (OPTION_USE_SYSTEM_LIBJPEG)
|
||||
target_link_libraries(fltk_images ${FLTK_JPEG_LIBRARIES})
|
||||
@ -524,6 +523,13 @@ endif (OPENGL_FOUND)
|
||||
# Build shared libraries (optional)
|
||||
#######################################################################
|
||||
|
||||
# Note to devs: As of 08 Aug 2016 we can build shared libs (dlls)
|
||||
# under Windows with Visual Studio (MSVC) but we can't link for instance
|
||||
# fltk_images_SHARED with fltk_SHARED - we have to use fltk, i.e. the
|
||||
# "static" object library instead. I don't know how to fix this, but
|
||||
# at least we can build shared libraries (dlls) with Visual Studio.
|
||||
# AlbrechtS
|
||||
|
||||
if (OPTION_BUILD_SHARED_LIBS)
|
||||
|
||||
FL_ADD_LIBRARY(fltk SHARED "${SHARED_FILES}")
|
||||
@ -532,12 +538,20 @@ if (OPTION_BUILD_SHARED_LIBS)
|
||||
###################################################################
|
||||
|
||||
FL_ADD_LIBRARY(fltk_forms SHARED "${FLCPPFILES}")
|
||||
target_link_libraries(fltk_forms_SHARED fltk_SHARED)
|
||||
if (MSVC)
|
||||
target_link_libraries(fltk_forms_SHARED fltk)
|
||||
else ()
|
||||
target_link_libraries(fltk_forms_SHARED fltk_SHARED)
|
||||
endif (MSVC)
|
||||
|
||||
###################################################################
|
||||
|
||||
FL_ADD_LIBRARY(fltk_images SHARED "${IMGCPPFILES}")
|
||||
target_link_libraries(fltk_images_SHARED fltk_SHARED)
|
||||
if (MSVC)
|
||||
target_link_libraries(fltk_images_SHARED fltk)
|
||||
else ()
|
||||
target_link_libraries(fltk_images_SHARED fltk_SHARED)
|
||||
endif (MSVC)
|
||||
|
||||
if (OPTION_USE_SYSTEM_LIBJPEG)
|
||||
target_link_libraries(fltk_images_SHARED ${FLTK_JPEG_LIBRARIES})
|
||||
@ -560,8 +574,12 @@ if (OPTION_BUILD_SHARED_LIBS)
|
||||
###################################################################
|
||||
|
||||
if (OPENGL_FOUND)
|
||||
FL_ADD_LIBRARY(fltk_gl SHARED "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}")
|
||||
target_link_libraries(fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES})
|
||||
FL_ADD_LIBRARY(fltk_gl SHARED "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}")
|
||||
if (MSVC)
|
||||
target_link_libraries(fltk_gl_SHARED fltk ${OPENGL_LIBRARIES})
|
||||
else ()
|
||||
target_link_libraries(fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES})
|
||||
endif (MSVC)
|
||||
endif (OPENGL_FOUND)
|
||||
|
||||
endif (OPTION_BUILD_SHARED_LIBS)
|
||||
|
Loading…
Reference in New Issue
Block a user