Skip to content

Instantly share code, notes, and snippets.

@su-v
Last active August 29, 2015 14:20
Show Gist options
  • Save su-v/c15cffe3b73c092ef397 to your computer and use it in GitHub Desktop.
Save su-v/c15cffe3b73c092ef397 to your computer and use it in GitHub Desktop.
Testing cmake build system for Inkscape 0.91+devel on Mac OS X 10.7.5
Chillida:cmake-build su_v$ make
[ 0%] Built target depixelize_LIB
[ 0%] Built target inkscape_version
[ 1%] Built target util_LIB
[ 6%] Built target 2geom_LIB
[ 7%] Built target avoid_LIB
[ 8%] Built target cola_LIB
[ 11%] Built target croco_LIB
[ 11%] Built target gc_LIB
[ 13%] Built target gdl_LIB
[ 14%] Built target uemf_LIB
[ 15%] Built target vpsc_LIB
[ 17%] Built target livarot_LIB
[ 19%] Built target nrtype_LIB
Linking CXX executable ../bin/inkscape
now run: "make install" to copy runtime files & scripts to /Users/su_v/TEMP/inkscape-repo/cmake-install
[100%] Built target inkscape
$ ./bin/inkscape -V
** (process:7344): WARNING **: Units file /Users/su_v/TEMP/inkscape-repo/cmake-install/share/inkscape/ui/units.xml is missing: Failed to open file '/Users/su_v/TEMP/inkscape-repo/cmake-install/share/inkscape/ui/units.xml': No such file or directory
Inkscape 0.91+devel 14078 (Apr 30 2015)
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-04-29 14:12:49 +0000
+++ CMakeLists.txt 2015-04-30 18:19:38 +0000
@@ -29,6 +29,30 @@
endif()
endif()
+#
+# Set platform defaults (originally copied from darktable)
+#
+if(APPLE)
+ message("-- Mac OS X build detected, setting default features")
+ # prefer macports and/or user-installed libraries over system ones
+ #LIST(APPEND CMAKE_PREFIX_PATH /opt/local /usr/local)
+ set(CMAKE_FIND_FRAMEWORK "LAST")
+
+ # test and display relevant env variables
+ if(DEFINED ENV{CMAKE_PREFIX_PATH})
+ message("CMAKE_PREFIX_PATH: $ENV{CMAKE_PREFIX_PATH}")
+ endif()
+ if(DEFINED ENV{GTKMM_BASEPATH})
+ message("GTKMM_BASEPATH: $ENV{GTKMM_BASEPATH}")
+ endif()
+
+ # detect current GTK+ backend
+ include(${CMAKE_SOURCE_DIR}/CMakeScripts/HelperFunctions.cmake)
+ pkg_check_variable(gtk+-2.0 target)
+ message("GTK2 backend: ${GTK+_2.0_TARGET}")
+
+endif(APPLE)
+
#-----------------------------------------------------------------------------
# Redirect output files
=== modified file 'CMakeScripts/DefineDependsandFlags.cmake'
--- CMakeScripts/DefineDependsandFlags.cmake 2015-04-29 23:25:17 +0000
+++ CMakeScripts/DefineDependsandFlags.cmake 2015-04-30 18:22:43 +0000
@@ -24,6 +24,31 @@
list(APPEND INKSCAPE_LIBS "-lpangoft2-1.0.dll") # FIXME
list(APPEND INKSCAPE_LIBS "-lpangowin32-1.0.dll") # FIXME
list(APPEND INKSCAPE_LIBS "-lgthread-2.0.dll") # FIXME
+elseif(APPLE)
+ if(DEFINED ENV{CMAKE_PREFIX_PATH})
+ # Adding the library search path explicitly seems not required
+ # if MacPorts is installed in default prefix ('/opt/local') -
+ # Cmake then can rely on the hard-coded paths in its modules.
+ # Only prepend search path if $CMAKE_PREFIX_PATH is defined:
+ list(APPEND INKSCAPE_LIBS "-L$ENV{CMAKE_PREFIX_PATH}/lib") # FIXME
+ # TODO: verify whether linking the next two libs explicitly is always
+ # required, or only if MacPorts is installed in custom prefix:
+ list(APPEND INKSCAPE_LIBS "-liconv") # FIXME
+ list(APPEND INKSCAPE_LIBS "-lintl") # FIXME
+ endif()
+ list(APPEND INKSCAPE_LIBS "-lpangocairo-1.0") # FIXME
+ list(APPEND INKSCAPE_LIBS "-lpangoft2-1.0") # FIXME
+ list(APPEND INKSCAPE_LIBS "-lfontconfig") # FIXME
+ # GTK+ backend
+ if(${GTK+_2.0_TARGET} MATCHES "x11")
+ # only link X11 if using X11 backend of GTK2
+ list(APPEND INKSCAPE_LIBS "-lX11") # FIXME
+ elseif(${GTK+_2.0_TARGET} MATCHES "quartz")
+ # TODO: gtk-mac-integration (currently only useful for osxmenu branch)
+ # 1) add configure option (ON/OFF) for gtk-mac-integration
+ # 2) add checks (GTK+ backend must be "quartz")
+ # 3) link relevant lib(s)
+ endif()
else()
list(APPEND INKSCAPE_LIBS "-ldl") # FIXME
list(APPEND INKSCAPE_LIBS "-lpangocairo-1.0") # FIXME
@@ -32,7 +57,10 @@
list(APPEND INKSCAPE_LIBS "-lX11") # FIXME
endif()
-list(APPEND INKSCAPE_LIBS "-lgomp") # FIXME
+if(NOT APPLE)
+ # FIXME: should depend on availability of OpenMP support (see below) (?)
+ list(APPEND INKSCAPE_LIBS "-lgomp") # FIXME
+endif()
list(APPEND INKSCAPE_LIBS "-lgslcblas") # FIXME
if(WITH_GNOME_VFS)
=== added file 'CMakeScripts/HelperFunctions.cmake'
--- CMakeScripts/HelperFunctions.cmake 1970-01-01 00:00:00 +0000
+++ CMakeScripts/HelperFunctions.cmake 2015-04-30 17:22:07 +0000
@@ -0,0 +1,19 @@
+# pkg_check_variable() - a function to retrieve pkg-config variables in CMake
+#
+# source: http://bloerg.net/2015/03/06/pkg-config-variables-in-cmake.html
+
+find_package(PkgConfig REQUIRED)
+
+function(pkg_check_variable _pkg _name)
+ string(TOUPPER ${_pkg} _pkg_upper)
+ string(TOUPPER ${_name} _name_upper)
+ string(REPLACE "-" "_" _pkg_upper ${_pkg_upper})
+ string(REPLACE "-" "_" _name_upper ${_name_upper})
+ set(_output_name "${_pkg_upper}_${_name_upper}")
+
+ execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_name} ${_pkg}
+ OUTPUT_VARIABLE _pkg_result
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ set("${_output_name}" "${_pkg_result}" CACHE STRING "pkg-config variable ${_name} of ${_pkg}")
+endfunction()
Known issues - general:
- poppler >= 0.29 not supported (breaks build)
- newer librevenge-based input formats (libwpg, libcdr, libvisio)
not supported (see related sections in configure.ac)
- CMake's module for ImageMagick seems outdated and misses defines [1]
- ...
Known issues - OS X:
- failing tests in ConfigChecks.cmake (e.g. to detect existing gtk
features) - missing includes/libs for the predefined tests?
- no checks for gtk backend (don't pull in X11 unless used, configure
for gtk-mac-integration (future))
- workarounds for linker failures seem too simplistic compared to the
tests done by autotools-based build system (--> simply adding
'-liconv -lintl' is likely to break on other systems (?))
- Cmake's FindFreetype.cmake module still lists path name of older
freetype versions first [2]. This causes cmake to opportunistically
detect an older version of freetype which happens to be installed on
the local system (Lion's original X11 in /usr/X11R6 --> /usr/X11),
completely outside any configured prefixes. Deleting the (incorrect)
name in a local copy of the module works around this issue.
- ... (to be continued)
References:
===========
[1] see also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776832
[2] https://github.com/Kitware/CMake/blob/master/Modules/FindFreetype.cmake#L76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment