| |
@@ -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}.")
|
| |
Needed for https://src.fedoraproject.org/rpms/lib3mf/pull-request/2