FindTBB.cmake 1.4 KB

123456789101112131415161718192021222324252627282930
  1. # This is a wrapper of FindTBB which prefers the config scripts if available in the system
  2. # but only if building with dynamic dependencies. The config scripts potentially belong
  3. # to TBB >= 2020 which is incompatible with OpenVDB in our static dependency bundle.
  4. # This workaround is useful for package maintainers on Linux systems to use newer versions
  5. # of intel TBB (renamed to oneTBB from version 2021 up).
  6. set(_q "")
  7. if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
  8. set(_q QUIET)
  9. endif()
  10. # Only consider the config scripts if not building with the static dependencies
  11. # and this call is not made from a static dependency build (e.g. dep_OpenVDB will use this module)
  12. # BUILD_SHARED_LIBS will always be defined for dependency projects and will be OFF.
  13. # Newer versions of TBB also discourage from using TBB as a static library
  14. if (NOT SLIC3R_STATIC AND (NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS))
  15. find_package(${CMAKE_FIND_PACKAGE_NAME} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} CONFIG ${_q})
  16. if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
  17. if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND)
  18. message(STATUS "Falling back to MODULE search for ${CMAKE_FIND_PACKAGE_NAME}...")
  19. else()
  20. message(STATUS "${CMAKE_FIND_PACKAGE_NAME} found in ${${CMAKE_FIND_PACKAGE_NAME}_DIR}")
  21. endif()
  22. endif()
  23. endif ()
  24. if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND)
  25. include(${CMAKE_CURRENT_LIST_DIR}/FindTBB.cmake.in)
  26. endif ()