summaryrefslogtreecommitdiffstats
path: root/CMakeScripts
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2015-05-01 03:52:17 +0000
committer~suv <suv-sf@users.sourceforge.net>2015-05-01 03:52:17 +0000
commit3c185d781ac7a7031397c6651baf046d900efc3a (patch)
tree0ceed4b570a0c57a48e7bbff12c255f751959ef0 /CMakeScripts
parentFixed crash bug due to some overlooked function changed in the recent merge. (diff)
downloadinkscape-3c185d781ac7a7031397c6651baf046d900efc3a.tar.gz
inkscape-3c185d781ac7a7031397c6651baf046d900efc3a.zip
cmake: Fix osx-related issues with cmake-build
Add new helper function to retrive pkg-config variables in Cmake; use paths defined as environment variables for builds on OS X (useful if MacPorts is not installed into default prefix); check backend of GTK2 on OS X in main cmake file (x11|quartz). (bzr r14080)
Diffstat (limited to 'CMakeScripts')
-rw-r--r--CMakeScripts/DefineDependsandFlags.cmake30
-rw-r--r--CMakeScripts/HelperFunctions.cmake19
2 files changed, 48 insertions, 1 deletions
diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake
index 637e48d6a..b0e5aa8b2 100644
--- a/CMakeScripts/DefineDependsandFlags.cmake
+++ b/CMakeScripts/DefineDependsandFlags.cmake
@@ -24,6 +24,31 @@ if (WIN32)
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 @@ else()
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)
diff --git a/CMakeScripts/HelperFunctions.cmake b/CMakeScripts/HelperFunctions.cmake
new file mode 100644
index 000000000..0e6fff51a
--- /dev/null
+++ b/CMakeScripts/HelperFunctions.cmake
@@ -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()