diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-02-28 14:56:19 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-03-01 10:45:59 +0100 |
| commit | 49a78bc482bc112248a05f0b1ea78bcf80403efa (patch) | |
| tree | f57c0c1a98e240a64cb2a05fdea19d6781a5ab87 /CMake | |
| parent | 266b5e7cddaaca312b77abd5696e0281af3251c9 (diff) | |
Fix cairo build (autoconf + CMake) + README's
- rewrite to use pkg-config with both autoconf + CMake
- remove hardcoded library names
- fix build dependencies and search directories
- remove or replace old and unused variables
- update README files
To be done:
- implement fallback for autoconf/configure if pkg-config is missing
- fix pango build (uses cairo internally)
Diffstat (limited to 'CMake')
| -rw-r--r-- | CMake/fl_create_example.cmake | 4 | ||||
| -rw-r--r-- | CMake/fl_debug_var.cmake | 4 | ||||
| -rw-r--r-- | CMake/options.cmake | 66 | ||||
| -rw-r--r-- | CMake/resources.cmake | 17 |
4 files changed, 66 insertions, 25 deletions
diff --git a/CMake/fl_create_example.cmake b/CMake/fl_create_example.cmake index dd4e1bc42..9053fa790 100644 --- a/CMake/fl_create_example.cmake +++ b/CMake/fl_create_example.cmake @@ -115,6 +115,10 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES) set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${NAME}) target_link_libraries (${TARGET_NAME} ${LIBRARIES}) + if (FLTK_HAVE_CAIRO) + target_link_directories (${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) + endif (FLTK_HAVE_CAIRO) + if (ICON_PATH) set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) set_target_properties (${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH}) diff --git a/CMake/fl_debug_var.cmake b/CMake/fl_debug_var.cmake index 4cecf3c7a..865f2a895 100644 --- a/CMake/fl_debug_var.cmake +++ b/CMake/fl_debug_var.cmake @@ -21,7 +21,7 @@ # # This macro displays the name and value of a CMake variable. # The variable name is expanded with spaces to be (at least) -# <min_len> (currently 24) characters wide for better readability. +# <min_len> (currently 30) characters wide for better readability. # VARNAME must be a string literal, e.g. WIN32 or "WIN32". # # Syntax: @@ -34,7 +34,7 @@ ####################################################################### macro (fl_debug_var name) - set (min_len 24) + set (min_len 30) set (var "${name}") string(LENGTH "${var}" len) while (len LESS min_len) diff --git a/CMake/options.cmake b/CMake/options.cmake index 142f345ee..008088a45 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -145,37 +145,63 @@ if (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) endif (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) ####################################################################### -include (FindPkgConfig) +# Include optional Cairo support +####################################################################### option (OPTION_CAIRO "use lib Cairo" OFF) option (OPTION_CAIROEXT "use FLTK code instrumentation for Cairo extended use" OFF ) -if ((OPTION_CAIRO OR OPTION_CAIROEXT) AND LIB_CAIRO) +set (FLTK_HAVE_CAIRO 0) +set (FLTK_USE_CAIRO 0) + +if (OPTION_CAIRO OR OPTION_CAIROEXT) pkg_search_module (PKG_CAIRO cairo) -endif ((OPTION_CAIRO OR OPTION_CAIROEXT) AND LIB_CAIRO) - -if (PKG_CAIRO_FOUND) - set (FLTK_HAVE_CAIRO 1) - add_subdirectory (cairo) - list (APPEND FLTK_LDLIBS -lcairo -lpixman-1) - include_directories (${PKG_CAIRO_INCLUDE_DIRS}) - string (REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}") - - if (LIB_CAIRO AND OPTION_CAIROEXT) - set (FLTK_USE_CAIRO 1) - set (FLTK_CAIRO_FOUND TRUE) + + # fl_debug_var (PKG_CAIRO_FOUND) + + if (PKG_CAIRO_FOUND) + set (FLTK_HAVE_CAIRO 1) + if (OPTION_CAIROEXT) + set (FLTK_USE_CAIRO 1) + endif (OPTION_CAIROEXT) + add_subdirectory (cairo) + + # fl_debug_var (PKG_CAIRO_INCLUDE_DIRS) + # fl_debug_var (PKG_CAIRO_CFLAGS) + # fl_debug_var (PKG_CAIRO_STATIC_CFLAGS) + # fl_debug_var (PKG_CAIRO_LIBRARIES) + # fl_debug_var (PKG_CAIRO_STATIC_LIBRARIES) + + include_directories (${PKG_CAIRO_INCLUDE_DIRS}) + + # Cairo libs and flags for fltk-config + + # Hint: use either PKG_CAIRO_* or PKG_CAIRO_STATIC_* variables to + # create the list of libraries used to link programs with cairo + # by running fltk-config --use-cairo --compile ... + # Currently we're using the non-STATIC variables to link cairo shared. + + set (CAIROLIBS) + foreach (lib ${PKG_CAIRO_LIBRARIES}) + list (APPEND CAIROLIBS "-l${lib}") + endforeach() + + string (REPLACE ";" " " CAIROLIBS "${CAIROLIBS}") + string (REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}") + + # fl_debug_var (FLTK_LDLIBS) + # fl_debug_var (CAIROFLAGS) + # fl_debug_var (CAIROLIBS) + else () - set (FLTK_CAIRO_FOUND FALSE) - endif (LIB_CAIRO AND OPTION_CAIROEXT) -else () - if (OPTION_CAIRO OR OPTION_CAIROEXT) message (STATUS "*** Cairo was requested but not found - please check your cairo installation") message (STATUS "*** or disable options OPTION_CAIRO and OPTION_CAIRO_EXT.") message (FATAL_ERROR "*** Terminating: missing Cairo libs or headers.") - endif (OPTION_CAIRO OR OPTION_CAIROEXT) -endif (PKG_CAIRO_FOUND) + endif (PKG_CAIRO_FOUND) + +endif (OPTION_CAIRO OR OPTION_CAIROEXT) ####################################################################### option (OPTION_USE_SVG "read/write SVG files" ON) diff --git a/CMake/resources.cmake b/CMake/resources.cmake index 3ec95b3b6..57173f206 100644 --- a/CMake/resources.cmake +++ b/CMake/resources.cmake @@ -2,7 +2,7 @@ # Resource definitions to build the FLTK project using CMake (www.cmake.org) # Written by Michael Surette # -# Copyright 1998-2020 by Bill Spitzak and others. +# Copyright 1998-2021 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 @@ -35,7 +35,19 @@ macro (fl_find_header VAR HEADER) endif (NOT CMAKE_REQUIRED_QUIET) endmacro (fl_find_header) +####################################################################### +# Include FindPkgConfig for later use of pkg-config +####################################################################### + +include (FindPkgConfig) + +# fl_debug_var (PKG_CONFIG_FOUND) +# fl_debug_var (PKG_CONFIG_EXECUTABLE) +# fl_debug_var (PKG_CONFIG_VERSION_STRING) + +####################################################################### # Find header files... +####################################################################### fl_find_header (HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h) fl_find_header (HAVE_DLFCN_H dlfcn.h) @@ -150,7 +162,6 @@ mark_as_advanced (FREETYPE_PATH) ####################################################################### # libraries -find_library (LIB_CAIRO cairo) find_library (LIB_dl dl) if ((NOT APPLE) OR OPTION_APPLE_X11) find_library (LIB_fontconfig fontconfig) @@ -163,7 +174,7 @@ find_library (LIB_jpeg jpeg) find_library (LIB_png png) find_library (LIB_zlib z) -mark_as_advanced (LIB_CAIRO LIB_dl LIB_fontconfig LIB_freetype) +mark_as_advanced (LIB_dl LIB_fontconfig LIB_freetype) mark_as_advanced (LIB_GL LIB_MesaGL LIB_GLEW) mark_as_advanced (LIB_jpeg LIB_png LIB_zlib) |
