diff options
Diffstat (limited to 'CMake')
| -rw-r--r-- | CMake/fl_create_example.cmake | 16 | ||||
| -rw-r--r-- | CMake/options.cmake | 78 |
2 files changed, 67 insertions, 27 deletions
diff --git a/CMake/fl_create_example.cmake b/CMake/fl_create_example.cmake index 303b5ea41..77fb24d0b 100644 --- a/CMake/fl_create_example.cmake +++ b/CMake/fl_create_example.cmake @@ -1,8 +1,8 @@ # -# A macro used by the CMake build system for the Fast Light Tool Kit (FLTK). -# Written by Michael Surette +# A function used by the CMake build system for the Fast Light Tool Kit (FLTK). +# Originally written by Michael Surette # -# Copyright 1998-2020 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 @@ -17,7 +17,7 @@ ################################################################################ # -# macro CREATE_EXAMPLE - Create a test/demo (example) program +# function CREATE_EXAMPLE - Create a test/demo (example) program # # Input: # @@ -119,13 +119,13 @@ function (CREATE_EXAMPLE NAME SOURCES LIBRARIES) set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${NAME}) target_link_libraries (${TARGET_NAME} ${LIBRARIES}) - # we must link all programs with fltk_cairo if option CAIROEXT is enabled + # we must link all programs with cairo if option CAIROEXT is enabled if (FLTK_HAVE_CAIROEXT) - target_link_libraries (${TARGET_NAME} fltk_cairo cairo) + target_link_libraries (${TARGET_NAME} ${PKG_CAIRO_LIBRARIES}) endif () - if (FLTK_HAVE_CAIRO) - fl_target_link_directories (${TARGET_NAME} PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}") + if (FLTK_HAVE_CAIRO AND PKG_CAIRO_LIBRARY_DIRS) + fl_target_link_directories (${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) endif () if (USE_GDIPLUS) # can only be true on Windows diff --git a/CMake/options.cmake b/CMake/options.cmake index e0235236d..392cb5cd6 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -412,19 +412,8 @@ if (OPTION_CAIRO OR OPTION_CAIROEXT) if (OPTION_CAIROEXT) set (FLTK_HAVE_CAIROEXT 1) endif (OPTION_CAIROEXT) - add_subdirectory (cairo) - - if (0) - fl_debug_var (PKG_CAIRO_INCLUDE_DIRS) - fl_debug_var (PKG_CAIRO_CFLAGS) - fl_debug_var (PKG_CAIRO_LIBRARIES) - fl_debug_var (PKG_CAIRO_LIBRARY_DIRS) - fl_debug_var (PKG_CAIRO_STATIC_INCLUDE_DIRS) - fl_debug_var (PKG_CAIRO_STATIC_CFLAGS) - fl_debug_var (PKG_CAIRO_STATIC_LIBRARIES) - fl_debug_var (PKG_CAIRO_STATIC_LIBRARY_DIRS) - endif() + ### FIXME ### include_directories (${PKG_CAIRO_INCLUDE_DIRS}) # Cairo libs and flags for fltk-config @@ -442,16 +431,67 @@ if (OPTION_CAIRO OR OPTION_CAIROEXT) string (REPLACE ";" " " CAIROLIBS "${CAIROLIBS}") string (REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}") - # fl_debug_var (FLTK_LDLIBS) - # fl_debug_var (CAIROFLAGS) - # fl_debug_var (CAIROLIBS) + else (PKG_CAIRO_FOUND) + + if (NOT MSVC) + 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 () + + # Tweak Cairo includes / libs / paths for Visual Studio (TEMPORARY solution). + # Todo: find a better way to set the required variables and flags! + # AlbrechtS 03/2023 + + message (STATUS "--- Cairo not found: trying to find Cairo for MSVC ...") + + if (NOT FLTK_CAIRO_DIR) + message (STATUS "--- Please set FLTK_CAIRO_DIR to point at the Cairo installation folder ...") + message (STATUS " ... with files 'include/cairo.h' and 'lib/x64/cairo.lib'") + message (STATUS "--- Example: cmake -DFLTK_CAIRO_DIR=\"C:/cairo-windows\" ...") + message (STATUS "--- Note: this will be changed in the future; currently only 64-bit supported") + message (FATAL_ERROR "*** Terminating: missing Cairo libs or headers.") + endif () + + set (CAIROLIBS "-lcairo") # should be correct: needs cairo.lib + + # simulate results of 'pkg_search_module (PKG_CAIRO cairo)' and more (above) + # these variables will be used later + + set (PKG_CAIRO_LIBRARIES "cairo") + set (PKG_CAIRO_INCLUDE_DIRS "${FLTK_CAIRO_DIR}/include") + set (PKG_CAIRO_LIBRARY_DIRS "${FLTK_CAIRO_DIR}/lib/x64/") + + ### FIXME ### + include_directories (${PKG_CAIRO_INCLUDE_DIRS}) + + set (FLTK_HAVE_CAIRO 1) + if (OPTION_CAIROEXT) + set (FLTK_HAVE_CAIROEXT 1) + endif (OPTION_CAIROEXT) - else () - 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 (PKG_CAIRO_FOUND) + if (0) # 1 = DEBUG, 0 = no output + message (STATUS "--- options.cmake: Cairo related variables ---") + if (MSVC) + fl_debug_var (FLTK_CAIRO_DIR) + endif (MSVC) + fl_debug_var (PKG_CAIRO_INCLUDE_DIRS) + fl_debug_var (PKG_CAIRO_CFLAGS) + fl_debug_var (PKG_CAIRO_LIBRARIES) + fl_debug_var (PKG_CAIRO_LIBRARY_DIRS) + fl_debug_var (PKG_CAIRO_STATIC_INCLUDE_DIRS) + fl_debug_var (PKG_CAIRO_STATIC_CFLAGS) + fl_debug_var (PKG_CAIRO_STATIC_LIBRARIES) + fl_debug_var (PKG_CAIRO_STATIC_LIBRARY_DIRS) + message (STATUS "--- fltk-config/Cairo variables ---") + fl_debug_var (FLTK_LDLIBS) + fl_debug_var (CAIROFLAGS) + fl_debug_var (CAIROLIBS) + message (STATUS "--- End of Cairo related variables ---") + endif() # 1 = DEBUG, ... + endif (OPTION_CAIRO OR OPTION_CAIROEXT) ####################################################################### |
