#12 [does not work] Fix locating lib3mf >= 2.2 during build
Closed 2 years ago by churchyard. Opened 2 years ago by churchyard.
rpms/ churchyard/openscad lib3mf2.2  into  rawhide

@@ -0,0 +1,97 @@ 

+ diff --git a/CMakeLists.txt b/CMakeLists.txt

+ index 5455594..1e8be65 100644

+ --- a/CMakeLists.txt

+ +++ b/CMakeLists.txt

+ @@ -257,10 +257,15 @@ find_package(BISON REQUIRED QUIET)

+  message(STATUS "Bison: ${BISON_VERSION}")

+  

+  if(NOT MSVC)

+ -  find_package(Lib3MF REQUIRED QUIET)

+ -  add_definitions(${LIB3MF_CFLAGS})

+ -  include_directories(${LIB3MF_INCLUDE_DIRS})

+ -  list(APPEND COMMON_LIBRARIES ${LIB3MF_LIBRARIES})

+ +  find_package(Lib3MF QUIET)

+ +  if (LIB3MF_FOUND)

+ +    message(STATUS "lib3mf: ${LIB3MF_VERSION}")

+ +    add_definitions(${LIB3MF_CFLAGS})

+ +    include_directories(${LIB3MF_INCLUDE_DIRS})

+ +    list(APPEND COMMON_LIBRARIES ${LIB3MF_LIBRARIES})

+ +  else()

+ +    message(STATUS "lib3mf: disabled")

+ +  endif()

+  endif()

+  

+  # Output compilation database (compile_commands.json), so we can e.g. run clang-tidy or other tools separately

+ diff --git a/cmake/Modules/FindLib3MF.cmake b/cmake/Modules/FindLib3MF.cmake

+ index e6a6e6c..733e09b 100644

+ --- a/cmake/Modules/FindLib3MF.cmake

+ +++ b/cmake/Modules/FindLib3MF.cmake

+ @@ -15,13 +15,42 @@ message(STATUS "Searching for lib3mf.")

+  # We still fall back to the rest of detection code here.

+  # Travis CI Ubuntu Trusty environment has some issue with pkg-config

+  # not finding the version.

+ -pkg_check_modules(LIB3MF lib3MF)

+ +find_package(PkgConfig REQUIRED QUIET)

+ +pkg_check_modules(PC_LIB3MF lib3MF)

+ +

+ +# Check for 2.0 version pc file if 1.0 was not found.

+ +if (NOT PC_LIB3MF_FOUND)

+ +  pkg_check_modules(PC_LIB3MF lib3mf)

+ +endif()

+ +

+ +set(LIB3MF_VERSION ${PC_LIB3MF_VERSION})

+ +set(LIB3MF_FOUND ${PC_LIB3MF_FOUND})

+ +

+ +find_path(LIB3MF_INCLUDE_DIRS

+ +    NAMES Model/COM/NMR_DLLInterfaces.h lib3mf_implicit.hpp

+ +    HINTS $ENV{LIB3MF_INCLUDEDIR}

+ +          ${PC_LIB3MF_INCLUDEDIR}

+ +          ${PC_LIB3MF_INCLUDE_DIRS}

+ +    PATH_SUFFIXES lib3mf

+ +)

+ +

+ +find_library(LIB3MF_LIBRARIES

+ +    NAMES 3mf 3MF

+ +    HINTS $ENV{LIB3MF_LIBDIR}

+ +          ${PC_LIB3MF_LIBDIR}

+ +          ${PC_LIB3MF_LIBRARY_DIRS}

+ +)

+ +

+ +if("${LIB3MF_LIBRARIES}" STREQUAL "LIB3MF_LIBRARIES-NOTFOUND")

+ +  set(LIB3MF_LIBRARIES "")

+ +endif()

+  

+  # default to uppercase for 1.0 library name

+  set(LIB3MF_LIB "3MF")

+ +set(LIB3MF_API "API 1.x")

+  

+  # some distribution packages are missing version information for 2.0

+ -if (LIB3MF_VERSION STREQUAL "" AND LIB3MF_FOUND)

+ +if ("${LIB3MF_VERSION}" STREQUAL "" AND LIB3MF_FOUND)

+    if (EXISTS "/usr/include/lib3mf" AND EXISTS "/usr/include/lib3mf/lib3mf_implicit.hpp")

+      set(LIB3MF_VERSION "2.0.0")

+    endif()

+ @@ -45,7 +74,7 @@ if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")

+    endif()

+  endif()

+  

+ -if ("${LIB3MF_LIBDIR}" STREQUAL "")

+ +if ("${LIB3MF_LIBRARIES}" STREQUAL "")

+    if (EXISTS "/opt/include/lib3mf/Model/COM/NMR_DLLInterfaces.h")

+      set(LIB3MF_INCLUDE_DIRS "/opt/include/lib3mf" "/opt/include/lib3mf/Model/COM")

+      set(LIB3MF_LIBDIR "/opt/lib")

+ @@ -62,8 +91,12 @@ if ("${LIB3MF_LIBDIR}" STREQUAL "")

+    endif()

+  endif()

+  

+ -if (NOT ${LIB3MF_LIBDIR} STREQUAL "")

+ -  set(LIB3MF_LIBRARIES "-L${LIB3MF_LIBDIR}" "-l${LIB3MF_LIB} -lzip -lz")

+ +if (NOT "${LIB3MF_LIBDIR}" STREQUAL "")

+ +  set(LIB3MF_LIBRARIES "-L${LIB3MF_LIBDIR}" "-l${LIB3MF_LIB}")

+ +endif()

+ +

+ +if (NOT "${LIB3MF_LIBRARIES}" STREQUAL "")

+ +    set(LIB3MF_LIBRARIES "${LIB3MF_LIBRARIES} -lzip -lz")

+    set(LIB3MF_CFLAGS "-D__GCC -DENABLE_LIB3MF")

+    set(LIB3MF_FOUND TRUE)

+    message(STATUS "Found lib3mf in ${LIB3MF_LIBDIR}.")

file modified
+11 -5
@@ -1,26 +1,29 @@ 

  Name:           openscad

  Version:        2021.01

  %global upversion %{version}

- Release:        7%{?dist}

+ Release:        8%{?dist}

  Summary:        The Programmers Solid 3D CAD Modeller

  # COPYING contains a linking exception for CGAL

  # Appdata file is CC0

  # Examples are CC0

  License:        GPLv2 with exceptions and CC0

  URL:            http://www.%{name}.org/

- Source0:        http://files.%{name}.org/%{name}-%{upversion}.src.tar.gz

+ Source:         http://files.%{name}.org/%{name}-%{upversion}.src.tar.gz

  Patch0:         %{name}-polyclipping.patch

  

  # CGAL 5.3 fixes from https://github.com/openscad/openscad/pull/3844

- Patch1:         %{name}-cgal5.3.patch

+ Patch:          %{name}-cgal5.3.patch

  

  # Upstream backports:

  %global github  https://github.com/openscad/openscad

  

  # https://github.com/openscad/openscad/commit/9b79576c1ee9d57d0f4a5de5c1365bb87c548f36

- Patch2:         %{name}-2021.01-fix-overloaded-join.patch

+ Patch:          %{name}-2021.01-fix-overloaded-join.patch

  # https://github.com/openscad/openscad/commit/71f2831c0484c3f35cbf44e1d1dc2c857384100b

- Patch3:         %{name}-2021.01-cgal-build-fix.patch

+ Patch:          %{name}-2021.01-cgal-build-fix.patch

+ # https://github.com/openscad/openscad/commit/4f2d0172763014ee4056072d527b39121bdcc74b

+ # https://github.com/openscad/openscad/commit/f723d5d502e96ab5c25b11deddd8420a69167543

+ Patch:          %{name}-2021.01-lib3mf-2.2-fix-locating.patch

  

  

  BuildRequires:  CGAL-devel >= 3.6
@@ -224,6 +227,9 @@ 

  %{_datadir}/%{name}/libraries/MCAD/bitmap/*.scad

  

  %changelog

+ * Wed Mar 09 2022 Miro Hrončok <mhroncok@redhat.com> - 2021.01-8

+ - Fix locating lib3mf >= 2.2 during build

+ 

  * Fri Feb 11 2022 Tom Callaway <spot@fedoraproject.org> - 2021.01-7

  - apply upstream fix for build issue with overloaded join()

  - fix build against new CGAL 5.4