mirror of
https://github.com/fltk/fltk.git
synced 2026-03-23 15:35:11 +08:00
CMake: build shared libs with OPTION_CAIROEXT (issue #250)
- remove separate libfltk_cairo to avoid cyclic dependencies, but
- keep a dummy libfltk_cairo in 1.4.0 for backwards compatibility
- move cairo/Fl_Cairo.cxx to src/Fl_Cairo.cxx
- add preliminary Cairo support for Visual Studio (MSVC)
Static linking is not affected by this change, but users building
with hand-made Makefiles will have to remove libfltk_cairo starting
with FLTK 1.4.0. The dummy library can be linked for backwards
compatibility but it will be removed later (in 1.4.x or 1.5.0).
The shared FLTK library libfltk.{so|dylib|dll|..} depends on libcairo
if and only if FLTK is built with one of the Cairo options. This has
always been the case for OPTION_CAIROEXT but is now also true if only
OPTION_CAIRO is selected, i.e. FLTK programs linked with a Cairo
enabled shared FLTK library will also be linked with libcairo. The same
is true for configure options --enable-cairo and --enable-cairoext,
respectively.
Preliminary Cairo support for MSVC now detects a Cairo installation
using the CMake variable FLTK_CAIRO_DIR which must be set by the user.
Note that this feature is temporary and may be changed in the future
for a better and more comfortable version.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# CMakeLists.txt to build fluid for the FLTK project using CMake (www.cmake.org)
|
||||
#
|
||||
# Copyright 1998-2022 by Bill Spitzak and others.
|
||||
# Copyright 1998-2023 by Bill Spitzak and others.
|
||||
#
|
||||
# This library is free software. Distribution and use rights are outlined in
|
||||
# the file "COPYING" which should have been included with this file. If this
|
||||
@@ -114,13 +114,12 @@ else ()
|
||||
|
||||
endif ()
|
||||
|
||||
# we must link all programs with fltk_cairo if option CAIROEXT is enabled
|
||||
if (FLTK_HAVE_CAIROEXT)
|
||||
list (APPEND FLUID_LIBS fltk_cairo cairo)
|
||||
endif (FLTK_HAVE_CAIROEXT)
|
||||
|
||||
# we must link fluid with Cairo if OPTION_CAIRO is enabled
|
||||
if (FLTK_HAVE_CAIRO)
|
||||
fl_target_link_directories (fluid PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}")
|
||||
target_include_directories (fluid PRIVATE ${PKG_CAIRO_INCLUDE_DIRS})
|
||||
if (PKG_CAIRO_LIBRARY_DIRS)
|
||||
fl_target_link_directories (fluid PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
|
||||
endif ()
|
||||
endif (FLTK_HAVE_CAIRO)
|
||||
|
||||
if (USE_GDIPLUS) # can only be true on Windows
|
||||
@@ -137,11 +136,27 @@ if (WIN32)
|
||||
list (APPEND FLUID_TARGETS fluid-cmd)
|
||||
add_executable (fluid-cmd ${CPPFILES} ${HEADERFILES})
|
||||
target_link_libraries (fluid-cmd ${FLUID_LIBS})
|
||||
if (FLTK_HAVE_CAIRO)
|
||||
fl_target_link_directories (fluid-cmd PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}")
|
||||
endif (FLTK_HAVE_CAIRO)
|
||||
endif ()
|
||||
|
||||
# we must link fluid-cmd with Cairo if OPTION_CAIRO is enabled (same as above)
|
||||
if (FLTK_HAVE_CAIRO)
|
||||
target_include_directories (fluid-cmd PRIVATE ${PKG_CAIRO_INCLUDE_DIRS})
|
||||
if (PKG_CAIRO_LIBRARY_DIRS)
|
||||
fl_target_link_directories (fluid-cmd PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
|
||||
endif ()
|
||||
endif (FLTK_HAVE_CAIRO)
|
||||
endif (WIN32)
|
||||
|
||||
# Build fluid-shared (experimental)
|
||||
|
||||
if (OPTION_BUILD_SHARED_LIBS)
|
||||
list (APPEND FLUID_TARGETS fluid-shared)
|
||||
add_executable (fluid-shared ${CPPFILES} ${HEADERFILES})
|
||||
if (MSVC)
|
||||
target_link_libraries (fluid-shared fltk_SHARED)
|
||||
else ()
|
||||
target_link_libraries (fluid-shared fltk_images_SHARED)
|
||||
endif (MSVC)
|
||||
endif ()
|
||||
|
||||
# install fluid GUI and commandline tool
|
||||
|
||||
@@ -164,7 +179,7 @@ if (APPLE AND (NOT OPTION_APPLE_X11))
|
||||
# ## set_target_properties (fluid PROPERTIES RESOURCE ${ICON_PATH})
|
||||
|
||||
# install fluid GUI and commandline tools
|
||||
#install (TARGETS fluid DESTINATION "/Applications")
|
||||
# install (TARGETS fluid DESTINATION "/Applications")
|
||||
|
||||
# install command line tool
|
||||
install (PROGRAMS $<TARGET_FILE:fluid> DESTINATION ${FLTK_BINDIR})
|
||||
@@ -180,7 +195,7 @@ else()
|
||||
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
||||
)
|
||||
|
||||
endif (APPLE AND (NOT OPTION_APPLE_X11))
|
||||
endif (APPLE AND (NOT OPTION_APPLE_X11))
|
||||
|
||||
# install desktop files
|
||||
|
||||
|
||||
Reference in New Issue
Block a user