FindLib3MF.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #
  2. # Try to find 3MF library and include path.
  3. # Once done this will define
  4. #
  5. # LIB3MF_FOUND
  6. # LIB3MF_CFLAGS
  7. # LIB3MF_LIBDIR
  8. # LIB3MF_INCLUDE_DIRS
  9. # LIB3MF_LIBRARIES
  10. #
  11. # Don't specify REQUIRED here in case pkg-config fails.
  12. # We still fall back to the rest of detection code here.
  13. # Travis CI Ubuntu Trusty environment has some issue with pkg-config
  14. # not finding the version.
  15. #pkg_check_modules(LIB3MF lib3MF)
  16. # default to uppercase for 1.0 library name
  17. #set(LIB3MF_LIB "3MF")
  18. # some distribution packages are missing version information for 2.0
  19. #if (LIB3MF_VERSION STREQUAL "" AND LIB3MF_FOUND)
  20. # if (EXISTS "/usr/include/lib3mf" AND EXISTS "/usr/include/lib3mf/lib3mf_implicit.hpp")
  21. # set(LIB3MF_VERSION "2.0.0")
  22. # endif()
  23. #endif()
  24. #if (LIB3MF_VERSION VERSION_EQUAL 1.8.1 OR LIB3MF_VERSION VERSION_GREATER 1.8.1)
  25. # set(LIB3MF_API "API 1.x")
  26. #endif()
  27. #if (LIB3MF_VERSION VERSION_EQUAL 2.0.0 OR LIB3MF_VERSION VERSION_GREATER 2.0.0)
  28. #set(LIB3MF_API "API 2.x")
  29. set(LIB3MF_LIB "3mf")
  30. #add_definitions(-DLIB3MF_API_2)
  31. #endif()
  32. #if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
  33. if (EXISTS "${CMAKE_SOURCE_DIR}/thirdparty/lib3mf/install")
  34. message(STATUS "found lib3mf in thirdparty.")
  35. set(LIB3MF_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/thirdparty/lib3mf/install/include/Bindings/Cpp")
  36. set(LIB3MF_LIBDIR "${CMAKE_SOURCE_DIR}/thirdparty/lib3mf/install/lib")
  37. endif()
  38. #endif()
  39. #if ("${LIB3MF_LIBDIR}" STREQUAL "")
  40. # if (EXISTS "/opt/include/lib3mf/Model/COM/NMR_DLLInterfaces.h")
  41. # set(LIB3MF_INCLUDE_DIRS "/opt/include/lib3mf" "/opt/include/lib3mf/Model/COM")
  42. # set(LIB3MF_LIBDIR "/opt/lib")
  43. # else()
  44. # if (EXISTS "/usr/local/include/lib3mf/Model/COM/NMR_DLLInterfaces.h")
  45. # set(LIB3MF_INCLUDE_DIRS "/usr/local/include/lib3mf" "/usr/local/include/lib3mf/Model/COM")
  46. # set(LIB3MF_LIBDIR "/usr/local/lib")
  47. # else()
  48. # if (EXISTS "/usr/include/lib3mf/Model/COM/NMR_DLLInterfaces.h")
  49. # set(LIB3MF_INCLUDE_DIRS "/usr/include/lib3mf" "/usr/include/lib3mf/Model/COM")
  50. # set(LIB3MF_LIBDIR "/usr/lib")
  51. # endif()
  52. # endif()
  53. # endif()
  54. #endif()
  55. if (NOT ${LIB3MF_LIBDIR} STREQUAL "")
  56. find_library(LIBZ_LIBRARY NAMES z)
  57. find_library(LIBZIP_LIBRARY NAMES zip)
  58. set(LIB3MF_LIBRARIES "-L${LIB3MF_LIBDIR}" "-l${LIB3MF_LIB} ${LIBZIP_LIBRARY} ${LIBZ_LIBRARY}")
  59. set(LIB3MF_FOUND TRUE)
  60. else()
  61. # set(LIB3MF_API "disabled")
  62. set(LIB3MF_FOUND FALSE)
  63. message(STATUS "Could not find lib3mf.")
  64. endif()