openvdb icon indicating copy to clipboard operation
openvdb copied to clipboard

[BUILD] Allow building openvdb in a super project with TBB on its side

Open Azrael3000 opened this issue 4 years ago • 0 comments

Environment

Operating System: all Version / Commit SHA: 36898a CMake Version: 3.20 Compiler: all

Describe the problem

If I put openvdb in a larger project with tbb on its side and use add_subdirectory for both of them and it still tries to find_package(TBB) even though the target is already there. The solution is quite simple and consists of adding a

if (NOT TARGET TBB::tbb) on line 123 of openvdb/openvdb/CMakeLists.txt so that the code becomes:

if (NOT TARGET TBB::tbb)
  find_package(TBB ${MINIMUM_TBB_VERSION} REQUIRED COMPONENTS tbb)
  if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_TBB_VERSION)
    if(${Tbb_VERSION} VERSION_LESS FUTURE_MINIMUM_TBB_VERSION)
      message(DEPRECATION "Support for TBB versions < ${FUTURE_MINIMUM_TBB_VERSION} "
        "is deprecated and will be removed.")
    endif()
  endif()
endif()

To Reproduce

Steps to reproduce the behavior:

  1. Checkout repo '...'
  2. Run CMake '....'
  3. Build with '....'
  4. See error

Additional context

(Add any other context about the problem here.)

Azrael3000 avatar Apr 28 '21 09:04 Azrael3000