summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-03-09 13:21:49 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-03-09 17:34:05 +0100
commit5175192755e57d1d7016253d48f34f9d0c2c0832 (patch)
tree6262a13668d6ea56067910b024516c60305e374e /src/CMakeLists.txt
parente32d4bcab990c2648bbcf550d115a5393c3f50e2 (diff)
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.
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r--src/CMakeLists.txt15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 40671d392..741d1f5b8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -172,6 +172,10 @@ set (CPPFILES
screen_xywh.cxx
)
+if (FLTK_HAVE_CAIRO) # OPTION_CAIRO or OPTION_CAIROEXT
+ list (APPEND CPPFILES Fl_Cairo.cxx)
+endif ()
+
# find all header files in source directory <FL/...>
file (GLOB
HEADER_FILES
@@ -616,6 +620,10 @@ if (HAVE_XRENDER)
list (APPEND OPTIONAL_LIBS ${X11_Xrender_LIB})
endif (HAVE_XRENDER)
+if (FLTK_HAVE_CAIRO) # OPTION_CAIRO or OPTION_CAIROEXT
+ list (APPEND OPTIONAL_LIBS ${PKG_CAIRO_LIBRARIES})
+endif()
+
if (USE_PANGO)
### FIXME ### This needs to use the PKG_* variables directly
list (APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGO} ${HAVE_LIB_PANGOCAIRO})
@@ -694,6 +702,10 @@ endif (UNIX AND OPTION_USE_WAYLAND)
FL_ADD_LIBRARY (fltk STATIC "${STATIC_FILES}")
target_link_libraries (fltk ${OPTIONAL_LIBS})
+if (FLTK_HAVE_CAIRO)
+ fl_target_link_directories (fltk PUBLIC "${PKG_CAIRO_LIBRARY_DIRS}")
+endif()
+
#######################################################################
FL_ADD_LIBRARY (fltk_forms STATIC "${FORMS_FILES}")
@@ -738,7 +750,8 @@ endif (OPENGL_FOUND)
if (OPTION_BUILD_SHARED_LIBS AND NOT MSVC)
FL_ADD_LIBRARY (fltk SHARED "${SHARED_FILES}")
- target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS})
+ target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS} ${PKG_CAIRO_LIBRARIES})
+ fl_target_link_directories (fltk_SHARED PUBLIC "${PKG_CAIRO_LIBRARY_DIRS}")
###################################################################