diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2020-01-14 23:20:31 -0500 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2020-05-31 22:12:12 -0400 |
commit | 89c34f5e48431de070c057cf4162a4519afbb0ba (patch) | |
tree | 58c69f17a4ce84be6bc6617c1cd3ad8ab4a6910a /gnu/packages | |
parent | ca3adf26072c759b198042ced866efc423dd4b97 (diff) | |
download | guix-89c34f5e48431de070c057cf4162a4519afbb0ba.tar.gz |
gnu: Add lib2geom.
* gnu/packages/graphics.scm (lib2geom): New variable. * gnu/packages/patches/lib2geom-enable-assertions.patch, lib2geom-link-tests-against-glib.patch, lib2geom-use-system-googletest.patch: New files. * gnu/local.mk (dist_patch_DATA): Register new patches.
Diffstat (limited to 'gnu/packages')
-rw-r--r-- | gnu/packages/graphics.scm | 77 | ||||
-rw-r--r-- | gnu/packages/patches/lib2geom-enable-assertions.patch | 36 | ||||
-rw-r--r-- | gnu/packages/patches/lib2geom-link-tests-against-glib.patch | 34 | ||||
-rw-r--r-- | gnu/packages/patches/lib2geom-use-system-googletest.patch | 94 |
4 files changed, 241 insertions, 0 deletions
diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm index 664e3fab45..75e6d48196 100644 --- a/gnu/packages/graphics.scm +++ b/gnu/packages/graphics.scm @@ -21,6 +21,7 @@ ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr> ;;; Copyright © 2020 Raghav Gururajan <raghavgururajan@disroot.org> +;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -61,6 +62,7 @@ #:use-module (gnu packages image) #:use-module (gnu packages imagemagick) #:use-module (gnu packages jemalloc) + #:use-module (gnu packages maths) #:use-module (gnu packages multiprecision) #:use-module (gnu packages pdf) #:use-module (gnu packages perl) @@ -328,6 +330,81 @@ quaternions and other useful 2D and 3D math functions. Iex is an exception-handling library.") (license license:bsd-3))) +(define-public lib2geom + ;; Use the latest master commit, as the 1.0 release suffer build problems. + (let ((revision "1") + (commit "42e119d94934a9514c61571cfb6b4af503ece082")) + (package + (name "lib2geom") + (version (git-version "1.0" revision commit)) + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://gitlab.com/inkscape/lib2geom.git") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "195rs0kdbs8w62irha1nwy83bccz04wglmk578qrj1mky7fc4rjv")) + (patches + ;; Patch submitted to upstream (see: + ;; https://gitlab.com/inkscape/lib2geom/merge_requests/17). + (search-patches "lib2geom-enable-assertions.patch")) + (modules '((guix build utils))) + (snippet + '(begin + ;; Fix py2geom module initialization (see: + ;; https://gitlab.com/inkscape/lib2geom/merge_requests/18). + (substitute* "src/py2geom/__init__.py" + (("_py2geom") "py2geom._py2geom")) + #t)))) + (build-system cmake-build-system) + (arguments + `(#:imported-modules ((guix build python-build-system) + ,@%cmake-build-system-modules) + #:configure-flags '("-D2GEOM_BUILD_SHARED=ON" + "-D2GEOM_BOOST_PYTHON=ON" + ;; Compiling the Cython bindings fail (see: + ;; https://gitlab.com/inkscape/lib2geom/issues/21). + "-D2GEOM_CYTHON_BINDINGS=OFF") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'patch-python-lib-install-path + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((python-version (@ (guix build python-build-system) + python-version)) + (python-maj-min-version (python-version + (assoc-ref inputs "python"))) + (site-package (string-append + (assoc-ref outputs "out") + "/lib/python" python-maj-min-version + "/site-packages"))) + (substitute* '("src/cython/CMakeLists.txt" + "src/py2geom/CMakeLists.txt") + (("PYTHON_LIB_INSTALL \"[^\"]*\"") + (format #f "PYTHON_LIB_INSTALL ~s" site-package)))) + #t))))) + (native-inputs `(("python" ,python-wrapper) + ("googletest" ,googletest) + ("pkg-config" ,pkg-config))) + (inputs `(("cairo" ,cairo) + ("pycairo" ,python-pycairo) + ("double-conversion" ,double-conversion) + ("glib" ,glib) + ("gsl" ,gsl))) + (propagated-inputs + `(("boost" ,boost))) ;referred to in 2geom/pathvector.h. + (home-page "https://gitlab.com/inkscape/lib2geom/") + (synopsis "C++ 2D graphics library") + (description "2geom is a C++ library of mathematics for paths, curves, +and other geometric calculations. Designed for vector graphics, it tackles +Bézier curves, conic sections, paths, intersections, transformations, and +basic geometries.") + ;; Because the library is linked with the GNU Scientific Library + ;; (GPLv3+), the combined work must be licensed as GPLv3+ (see: + ;; https://gitlab.com/inkscape/inkscape/issues/784). + (license license:gpl3+)))) + (define-public ogre (package (name "ogre") diff --git a/gnu/packages/patches/lib2geom-enable-assertions.patch b/gnu/packages/patches/lib2geom-enable-assertions.patch new file mode 100644 index 0000000000..8feb44acbf --- /dev/null +++ b/gnu/packages/patches/lib2geom-enable-assertions.patch @@ -0,0 +1,36 @@ +From 4aa78f52232682b353eb15c219171e466987bac7 Mon Sep 17 00:00:00 2001 +From: Maxim Cournoyer <maxim.cournoyer@gmail.com> +Date: Thu, 16 Jan 2020 00:19:29 -0500 +Subject: [PATCH] build: Enable assertions for the RelWithDebugInfo build type. + +This fixes issue #5 (see: +https://gitlab.com/inkscape/lib2geom/issues/5). + +* CMakeLists.txt: Remove the "-DNDEBUG" CXX flag from the default +configuration for the RelWithDebugInfo build type. +--- + CMakeLists.txt | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bfeb8f03..a663a1b0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -19,6 +19,14 @@ enable_testing() + + include(CheckCXXSourceCompiles) + ++# Enable assertions for the RelWithDebugInfo build type. This is ++# useful as some tests make use of it (see: ++# https://gitlab.com/inkscape/lib2geom/issues/5). ++if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") ++ string(REPLACE "-DNDEBUG" "" ++ CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") ++endif() ++ + # Find dependencies + find_package(Boost 1.40 REQUIRED) + find_package(DoubleConversion REQUIRED) +-- +2.24.1 + diff --git a/gnu/packages/patches/lib2geom-link-tests-against-glib.patch b/gnu/packages/patches/lib2geom-link-tests-against-glib.patch new file mode 100644 index 0000000000..2b4f7ca6bf --- /dev/null +++ b/gnu/packages/patches/lib2geom-link-tests-against-glib.patch @@ -0,0 +1,34 @@ +From f95925afef451755fc1449e57fbfdc2e7277f4b4 Mon Sep 17 00:00:00 2001 +From: Maxim Cournoyer <maxim.cournoyer@gmail.com> +Date: Sat, 11 Jan 2020 00:44:55 -0500 +Subject: [PATCH 1/3] tests: Link against GLib. + +This resolves an error about not finding <glib.h> when linking the +tests that make use of GLib. + +* src/tests/CMakeLists.txt[2GEOM_GTESTS_SRC]: Add the glib library to +the link target libraries. +--- + src/tests/CMakeLists.txt | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt +index 5ddf7f9c..626cfd87 100644 +--- a/src/tests/CMakeLists.txt ++++ b/src/tests/CMakeLists.txt +@@ -32,8 +32,10 @@ sbasis-test + + foreach(source ${2GEOM_GTESTS_SRC}) + add_executable(${source} ${source}.cpp) +- target_include_directories(${source} PRIVATE ${GSL_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS}) +- target_link_libraries(${source} 2geom gtest_main gtest ${GSL_LIBRARIES} ${GTK3_LIBRARIES}) ++ target_include_directories(${source} PRIVATE ${GSL_INCLUDE_DIRS} ++ ${GTK3_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS}) ++ target_link_libraries(${source} 2geom gtest_main gtest ${GSL_LIBRARIES} ++ ${GTK3_LIBRARIES} ${GLIB_LIBRARIES}) + add_test(NAME ${source} COMMAND ${source}) + endforeach() + +-- +2.24.1 + diff --git a/gnu/packages/patches/lib2geom-use-system-googletest.patch b/gnu/packages/patches/lib2geom-use-system-googletest.patch new file mode 100644 index 0000000000..16cce1799f --- /dev/null +++ b/gnu/packages/patches/lib2geom-use-system-googletest.patch @@ -0,0 +1,94 @@ +From 6693b9c8ff1ae1ec02c9002c0a8f5f416f0c88f0 Mon Sep 17 00:00:00 2001 +From: Maxim Cournoyer <maxim.cournoyer@gmail.com> +Date: Sun, 12 Jan 2020 23:23:33 -0500 +Subject: [PATCH 3/3] build: Prefer googletest from the system. + +Fixes issue #4. + +The build system now look for a system installed googletest or falls +back to the bundled copy of googletest otherwise. + +* CMakeLists.txt: Add call to find_package(GTest). +(include_directories): Remove "src/googletest/googletest/include" from +arg. +* src/CMakeLists.txt[NOT GTEST_FOUND]: Define the gtest and gtest_main +libraries when GTEST_FOUND is false. Globally include the googletest +headers here. Define aliases for the gtest and gtest_main libraries +that match those defined by the FindGTest module. +* src/tests/CMakeLists.txt: Replace references to gtest_main and gtest +by GTest::Main and GTest::GTest, respectively. +--- + CMakeLists.txt | 3 ++- + src/CMakeLists.txt | 15 +++++++++++---- + src/tests/CMakeLists.txt | 6 +++--- + 3 files changed, 16 insertions(+), 8 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bfeb8f03..96fbd58c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -25,13 +25,14 @@ find_package(DoubleConversion REQUIRED) + find_package(PkgConfig REQUIRED) + find_package(Cython) + find_package(Threads) ++find_package(GTest) + pkg_check_modules(GTK3 gtk+-3.0) + pkg_check_modules(GLIB glib-2.0) + pkg_check_modules(CAIRO cairo) + pkg_check_modules(GSL gsl) + + # Add global include and link directories +-include_directories(src src/googletest/googletest/include ${CMAKE_CURRENT_BINARY_DIR}) ++include_directories(src ${CMAKE_CURRENT_BINARY_DIR}) + link_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/2geom) + + check_cxx_source_compiles("#include <math.h>\nint main() { double a=0.5,b=0.5,c=0.5; sincos(a, &b, &c); return 0; }" HAVE_SINCOS) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index eefb3ac5..941dc4c7 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -1,7 +1,14 @@ +-add_library(gtest SHARED googletest/googletest/src/gtest-all.cc) +-target_include_directories(gtest PRIVATE googletest/googletest) +-target_link_libraries(gtest Threads::Threads) +-add_library(gtest_main STATIC googletest/googletest/src/gtest_main.cc) ++if(NOT GTEST_FOUND) ++ message("No system googletest library: using bundled copy.") ++ add_library(gtest SHARED googletest/googletest/src/gtest-all.cc) ++ add_library(gtest_main STATIC googletest/googletest/src/gtest_main.cc) ++ target_include_directories(gtest PRIVATE googletest/googletest) ++ target_link_libraries(gtest Threads::Threads) ++ include_directories(SYSTEM googletest/googletest/include) ++ # Aliases to share the same nomenclature with FindGTest. ++ add_library(GTest::GTest ALIAS gtest) ++ add_library(GTest::Main ALIAS gtest_main) ++endif() + + add_subdirectory(2geom) + add_subdirectory(tests) +diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt +index 626cfd87..3538f8cf 100644 +--- a/src/tests/CMakeLists.txt ++++ b/src/tests/CMakeLists.txt +@@ -34,15 +34,15 @@ foreach(source ${2GEOM_GTESTS_SRC}) + add_executable(${source} ${source}.cpp) + target_include_directories(${source} PRIVATE ${GSL_INCLUDE_DIRS} + ${GTK3_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS}) +- target_link_libraries(${source} 2geom gtest_main gtest ${GSL_LIBRARIES} +- ${GTK3_LIBRARIES} ${GLIB_LIBRARIES}) ++ target_link_libraries(${source} 2geom GTest::Main GTest::GTest ++ ${GSL_LIBRARIES} ${GTK3_LIBRARIES} ${GLIB_LIBRARIES}) + add_test(NAME ${source} COMMAND ${source}) + endforeach() + + foreach(source ${2GEOM_TESTS_SRC}) + add_executable(${source} ${source}.cpp) + target_include_directories(${source} PRIVATE ${GSL_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS}) +- target_link_libraries(${source} 2geom gtest ${GSL_LIBRARIES} ${GTK3_LIBRARIES}) ++ target_link_libraries(${source} 2geom GTest::GTest ${GSL_LIBRARIES} ${GTK3_LIBRARIES}) + add_test(NAME ${source} COMMAND ${source}) + endforeach(source) + +-- +2.24.1 + |