|
|
commit 787c67afea179735f2fea12f95ad04c80b3717e7
Author: Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Mon Jul 12 19:26:28 2021 +0200
Commit: Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Mon Jul 12 20:05:07 2021 +0200
macOS: fix fltk_cairo shared library (issue #250)
- add missing dependencies to build the shared libfltk_cairo(.dylib)
- remove incorrect dependency on cairo from libfltk
- add cairo_test-shared demo (linked with shared libs)
CMakeLists.txt | 2 +-
cairo/CMakeLists.txt | 24 +++++++++++++++++-------
src/CMakeLists.txt | 4 ----
test/CMakeLists.txt | 6 +++++-
4 files changed, 23 insertions(+), 13 deletions(-)
diff --git CMakeLists.txt CMakeLists.txt
index 7a05f6c..58e75be 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -211,7 +211,7 @@ feature_summary (WHAT ALL DESCRIPTION "Configuration Summary for ${_descr} --\n"
message (STATUS "Static libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
if (OPTION_BUILD_SHARED_LIBS)
- message (STATUS "Shared libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
+ message (STATUS "Shared libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
else ()
message (STATUS "Shared libraries will not be built (set OPTION_BUILD_SHARED_LIBS=ON to build)")
endif ()
diff --git cairo/CMakeLists.txt cairo/CMakeLists.txt
index 2cfa912..181f30e 100644
--- cairo/CMakeLists.txt
+++ cairo/CMakeLists.txt
@@ -1,17 +1,27 @@
-include_directories(${PKG_CAIRO_INCLUDE_DIRS})
+include_directories (${PKG_CAIRO_INCLUDE_DIRS})
# source files for cairo
-set(cairo_SRCS Fl_Cairo.cxx)
+set (cairo_SRCS Fl_Cairo.cxx)
#######################################################################
-FL_ADD_LIBRARY(fltk_cairo STATIC "${cairo_SRCS}")
+FL_ADD_LIBRARY (fltk_cairo STATIC "${cairo_SRCS}")
#######################################################################
-if(OPTION_BUILD_SHARED_LIBS)
+# Build shared library (optional)
#######################################################################
-FL_ADD_LIBRARY(fltk_cairo SHARED "${cairo_SRCS}")
-#######################################################################
-endif(OPTION_BUILD_SHARED_LIBS)
+if (OPTION_BUILD_SHARED_LIBS)
+
+ FL_ADD_LIBRARY (fltk_cairo SHARED "${cairo_SRCS}")
+ target_link_libraries (fltk_cairo_SHARED fltk_SHARED ${PKG_CAIRO_LIBRARIES})
+
+ if (CMAKE_VERSION VERSION_LESS "3.13")
+ link_directories (${PKG_CAIRO_LIBRARY_DIRS})
+ else()
+ target_link_directories (fltk_cairo_SHARED PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
+ endif()
+
+endif (OPTION_BUILD_SHARED_LIBS)
+
#######################################################################
diff --git src/CMakeLists.txt src/CMakeLists.txt
index 1a614be..274df8e 100644
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -519,10 +519,6 @@ if (WIN32)
list (APPEND OPTIONAL_LIBS comctl32 ws2_32)
endif (WIN32)
-if (FLTK_HAVE_CAIRO)
- list (APPEND OPTIONAL_LIBS fltk_cairo ${PKG_CAIRO_LIBRARIES})
-endif (FLTK_HAVE_CAIRO)
-
if (HAVE_XINERAMA)
list (APPEND OPTIONAL_LIBS ${X11_Xinerama_LIB})
endif (HAVE_XINERAMA)
diff --git test/CMakeLists.txt test/CMakeLists.txt
index 9c602ce..33df73a 100644
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -147,7 +147,7 @@ endif (OPENGL_FOUND)
# Cairo demo - must also be built w/o Cairo (displays a message box)
if (FLTK_HAVE_CAIRO)
- CREATE_EXAMPLE (cairo_test cairo_test.cxx "fltk_cairo;fltk")
+ CREATE_EXAMPLE (cairo_test cairo_test.cxx "fltk_cairo;fltk;cairo")
else ()
CREATE_EXAMPLE (cairo_test cairo_test.cxx fltk)
endif (FLTK_HAVE_CAIRO)
@@ -206,6 +206,10 @@ if (OPTION_BUILD_SHARED_LIBS)
CREATE_EXAMPLE (shape-shared shape.cxx "fltk_gl_SHARED;fltk_SHARED;${OPENGL_LIBRARIES}")
endif (OPENGL_FOUND)
+ if (FLTK_HAVE_CAIRO)
+ CREATE_EXAMPLE (cairo_test-shared cairo_test.cxx "fltk_cairo_SHARED;fltk_SHARED;cairo")
+ endif ()
+
endif (MSVC) # (not MSVC)
endif (OPTION_BUILD_SHARED_LIBS)
[ Direct Link to Message ] | |
|
| |