FindOpenVDB.cmake 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. # Copyright (c) DreamWorks Animation LLC
  2. #
  3. # All rights reserved. This software is distributed under the
  4. # Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
  5. #
  6. # Redistributions of source code must retain the above copyright
  7. # and license notice and the following restrictions and disclaimer.
  8. #
  9. # * Neither the name of DreamWorks Animation nor the names of
  10. # its contributors may be used to endorse or promote products derived
  11. # from this software without specific prior written permission.
  12. #
  13. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  14. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  15. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  16. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  17. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
  18. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  21. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. # IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
  25. # LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
  26. #
  27. #[=======================================================================[.rst:
  28. FindOpenVDB
  29. -----------
  30. Find OpenVDB include dirs, libraries and settings
  31. Use this module by invoking find_package with the form::
  32. find_package(OpenVDB
  33. [version] [EXACT] # Minimum or EXACT version
  34. [REQUIRED] # Fail with error if OpenVDB is not found
  35. [COMPONENTS <libs>...] # OpenVDB libraries by their canonical name
  36. # e.g. "openvdb" for "libopenvdb"
  37. )
  38. IMPORTED Targets
  39. ^^^^^^^^^^^^^^^^
  40. ``OpenVDB::openvdb``
  41. The core openvdb library target.
  42. Result Variables
  43. ^^^^^^^^^^^^^^^^
  44. This will define the following variables:
  45. ``OpenVDB_FOUND``
  46. True if the system has the OpenVDB library.
  47. ``OpenVDB_VERSION``
  48. The version of the OpenVDB library which was found.
  49. ``OpenVDB_INCLUDE_DIRS``
  50. Include directories needed to use OpenVDB.
  51. ``OpenVDB_LIBRARIES``
  52. Libraries needed to link to OpenVDB.
  53. ``OpenVDB_LIBRARY_DIRS``
  54. OpenVDB library directories.
  55. ``OpenVDB_DEFINITIONS``
  56. Definitions to use when compiling code that uses OpenVDB.
  57. ``OpenVDB_{COMPONENT}_FOUND``
  58. True if the system has the named OpenVDB component.
  59. ``OpenVDB_USES_BLOSC``
  60. True if the OpenVDB Library has been built with blosc support
  61. ``OpenVDB_USES_LOG4CPLUS``
  62. True if the OpenVDB Library has been built with log4cplus support
  63. ``OpenVDB_USES_EXR``
  64. True if the OpenVDB Library has been built with openexr support
  65. ``OpenVDB_ABI``
  66. Set if this module was able to determine the ABI number the located
  67. OpenVDB Library was built against. Unset otherwise.
  68. Cache Variables
  69. ^^^^^^^^^^^^^^^
  70. The following cache variables may also be set:
  71. ``OpenVDB_INCLUDE_DIR``
  72. The directory containing ``openvdb/version.h``.
  73. ``OpenVDB_{COMPONENT}_LIBRARY``
  74. Individual component libraries for OpenVDB
  75. Hints
  76. ^^^^^
  77. Instead of explicitly setting the cache variables, the following variables
  78. may be provided to tell this module where to look.
  79. ``OPENVDB_ROOT``
  80. Preferred installation prefix.
  81. ``OPENVDB_INCLUDEDIR``
  82. Preferred include directory e.g. <prefix>/include
  83. ``OPENVDB_LIBRARYDIR``
  84. Preferred library directory e.g. <prefix>/lib
  85. ``SYSTEM_LIBRARY_PATHS``
  86. Paths appended to all include and lib searches.
  87. #]=======================================================================]
  88. cmake_minimum_required(VERSION 3.3)
  89. # Monitoring <PackageName>_ROOT variables
  90. if(POLICY CMP0074)
  91. cmake_policy(SET CMP0074 NEW)
  92. endif()
  93. # Include utility functions for version information
  94. include(${CMAKE_CURRENT_LIST_DIR}/OpenVDBUtils.cmake)
  95. mark_as_advanced(
  96. OpenVDB_INCLUDE_DIR
  97. OpenVDB_LIBRARY
  98. )
  99. set(_OPENVDB_COMPONENT_LIST
  100. openvdb
  101. )
  102. if(OpenVDB_FIND_COMPONENTS)
  103. set(OPENVDB_COMPONENTS_PROVIDED TRUE)
  104. set(_IGNORED_COMPONENTS "")
  105. foreach(COMPONENT ${OpenVDB_FIND_COMPONENTS})
  106. if(NOT ${COMPONENT} IN_LIST _OPENVDB_COMPONENT_LIST)
  107. list(APPEND _IGNORED_COMPONENTS ${COMPONENT})
  108. endif()
  109. endforeach()
  110. if(_IGNORED_COMPONENTS)
  111. message(STATUS "Ignoring unknown components of OpenVDB:")
  112. foreach(COMPONENT ${_IGNORED_COMPONENTS})
  113. message(STATUS " ${COMPONENT}")
  114. endforeach()
  115. list(REMOVE_ITEM OpenVDB_FIND_COMPONENTS ${_IGNORED_COMPONENTS})
  116. endif()
  117. else()
  118. set(OPENVDB_COMPONENTS_PROVIDED FALSE)
  119. set(OpenVDB_FIND_COMPONENTS ${_OPENVDB_COMPONENT_LIST})
  120. endif()
  121. # Append OPENVDB_ROOT or $ENV{OPENVDB_ROOT} if set (prioritize the direct cmake var)
  122. set(_OPENVDB_ROOT_SEARCH_DIR "")
  123. # Additionally try and use pkconfig to find OpenVDB
  124. find_package(PkgConfig)
  125. pkg_check_modules(PC_OpenVDB QUIET OpenVDB)
  126. # ------------------------------------------------------------------------
  127. # Search for OpenVDB include DIR
  128. # ------------------------------------------------------------------------
  129. set(_OPENVDB_INCLUDE_SEARCH_DIRS "")
  130. list(APPEND _OPENVDB_INCLUDE_SEARCH_DIRS
  131. ${OPENVDB_INCLUDEDIR}
  132. ${_OPENVDB_ROOT_SEARCH_DIR}
  133. ${PC_OpenVDB_INCLUDE_DIRS}
  134. ${SYSTEM_LIBRARY_PATHS}
  135. )
  136. # Look for a standard OpenVDB header file.
  137. find_path(OpenVDB_INCLUDE_DIR openvdb/version.h
  138. PATHS ${_OPENVDB_INCLUDE_SEARCH_DIRS}
  139. PATH_SUFFIXES include
  140. )
  141. OPENVDB_VERSION_FROM_HEADER("${OpenVDB_INCLUDE_DIR}/openvdb/version.h"
  142. VERSION OpenVDB_VERSION
  143. MAJOR OpenVDB_MAJOR_VERSION
  144. MINOR OpenVDB_MINOR_VERSION
  145. PATCH OpenVDB_PATCH_VERSION
  146. )
  147. # ------------------------------------------------------------------------
  148. # Search for OPENVDB lib DIR
  149. # ------------------------------------------------------------------------
  150. set(_OPENVDB_LIBRARYDIR_SEARCH_DIRS "")
  151. # Append to _OPENVDB_LIBRARYDIR_SEARCH_DIRS in priority order
  152. list(APPEND _OPENVDB_LIBRARYDIR_SEARCH_DIRS
  153. ${OPENVDB_LIBRARYDIR}
  154. ${_OPENVDB_ROOT_SEARCH_DIR}
  155. ${PC_OpenVDB_LIBRARY_DIRS}
  156. ${SYSTEM_LIBRARY_PATHS}
  157. )
  158. # Build suffix directories
  159. set(OPENVDB_PATH_SUFFIXES
  160. lib64
  161. lib
  162. )
  163. # Static library setup
  164. if(UNIX AND OPENVDB_USE_STATIC_LIBS)
  165. set(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  166. set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
  167. endif()
  168. set(OpenVDB_LIB_COMPONENTS "")
  169. set(OpenVDB_DEBUG_SUFFIX "d" CACHE STRING "Suffix for the debug libraries")
  170. get_property(_is_multi GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
  171. foreach(COMPONENT ${OpenVDB_FIND_COMPONENTS})
  172. set(LIB_NAME ${COMPONENT})
  173. find_library(OpenVDB_${COMPONENT}_LIBRARY_RELEASE ${LIB_NAME} lib${LIB_NAME}
  174. PATHS ${_OPENVDB_LIBRARYDIR_SEARCH_DIRS}
  175. PATH_SUFFIXES ${OPENVDB_PATH_SUFFIXES}
  176. )
  177. find_library(OpenVDB_${COMPONENT}_LIBRARY_DEBUG ${LIB_NAME}${OpenVDB_DEBUG_SUFFIX} lib${LIB_NAME}${OpenVDB_DEBUG_SUFFIX}
  178. PATHS ${_OPENVDB_LIBRARYDIR_SEARCH_DIRS}
  179. PATH_SUFFIXES ${OPENVDB_PATH_SUFFIXES}
  180. )
  181. if (_is_multi)
  182. list(APPEND OpenVDB_LIB_COMPONENTS ${OpenVDB_${COMPONENT}_LIBRARY_RELEASE} ${OpenVDB_${COMPONENT}_LIBRARY_DEBUG})
  183. list(FIND CMAKE_CONFIGURATION_TYPES "Debug" _has_debug)
  184. if(OpenVDB_${COMPONENT}_LIBRARY_RELEASE AND (_has_debug LESS 0 OR OpenVDB_${COMPONENT}_LIBRARY_DEBUG))
  185. set(OpenVDB_${COMPONENT}_FOUND TRUE)
  186. else()
  187. set(OpenVDB_${COMPONENT}_FOUND FALSE)
  188. endif()
  189. else ()
  190. string(TOUPPER "${CMAKE_BUILD_TYPE}" _BUILD_TYPE)
  191. set(OpenVDB_${COMPONENT}_LIBRARY ${OpenVDB_${COMPONENT}_LIBRARY_${_BUILD_TYPE}})
  192. if (NOT MSVC AND NOT OpenVDB_${COMPONENT}_LIBRARY)
  193. set(OpenVDB_${COMPONENT}_LIBRARY ${OpenVDB_${COMPONENT}_LIBRARY_RELEASE})
  194. endif ()
  195. list(APPEND OpenVDB_LIB_COMPONENTS ${OpenVDB_${COMPONENT}_LIBRARY})
  196. if(OpenVDB_${COMPONENT}_LIBRARY)
  197. set(OpenVDB_${COMPONENT}_FOUND TRUE)
  198. else()
  199. set(OpenVDB_${COMPONENT}_FOUND FALSE)
  200. endif()
  201. endif ()
  202. endforeach()
  203. if(UNIX AND OPENVDB_USE_STATIC_LIBS)
  204. set(CMAKE_FIND_LIBRARY_SUFFIXES ${_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  205. unset(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
  206. endif()
  207. # ------------------------------------------------------------------------
  208. # Cache and set OPENVDB_FOUND
  209. # ------------------------------------------------------------------------
  210. include(FindPackageHandleStandardArgs)
  211. find_package_handle_standard_args(OpenVDB
  212. FOUND_VAR OpenVDB_FOUND
  213. REQUIRED_VARS
  214. OpenVDB_INCLUDE_DIR
  215. OpenVDB_LIB_COMPONENTS
  216. VERSION_VAR OpenVDB_VERSION
  217. HANDLE_COMPONENTS
  218. )
  219. # ------------------------------------------------------------------------
  220. # Determine ABI number
  221. # ------------------------------------------------------------------------
  222. # Set the ABI number the library was built against. Uses vdb_print
  223. find_program(OPENVDB_PRINT vdb_print PATHS ${OpenVDB_INCLUDE_DIR} )
  224. OPENVDB_ABI_VERSION_FROM_PRINT(
  225. "${OPENVDB_PRINT}"
  226. ABI OpenVDB_ABI
  227. )
  228. if(NOT OpenVDB_FIND_QUIET)
  229. if(NOT OpenVDB_ABI)
  230. message(WARNING "Unable to determine OpenVDB ABI version from OpenVDB "
  231. "installation. The library major version \"${OpenVDB_MAJOR_VERSION}\" "
  232. "will be inferred. If this is not correct, use "
  233. "add_definitions(-DOPENVDB_ABI_VERSION_NUMBER=N)"
  234. )
  235. else()
  236. message(STATUS "OpenVDB ABI Version: ${OpenVDB_ABI}")
  237. endif()
  238. endif()
  239. # ------------------------------------------------------------------------
  240. # Handle OpenVDB dependencies
  241. # ------------------------------------------------------------------------
  242. # Add standard dependencies
  243. find_package(IlmBase COMPONENTS Half)
  244. if(NOT IlmBase_FOUND)
  245. pkg_check_modules(IlmBase QUIET IlmBase)
  246. endif()
  247. if (IlmBase_FOUND AND NOT TARGET IlmBase::Half)
  248. message(STATUS "Falling back to IlmBase found by pkg-config...")
  249. find_library(IlmHalf_LIBRARY NAMES Half)
  250. if(IlmHalf_LIBRARY-NOTFOUND)
  251. message(FATAL_ERROR "IlmBase::Half can not be found!")
  252. endif()
  253. add_library(IlmBase::Half UNKNOWN IMPORTED)
  254. set_target_properties(IlmBase::Half PROPERTIES
  255. IMPORTED_LOCATION "${IlmHalf_LIBRARY}"
  256. INTERFACE_INCLUDE_DIRECTORIES ${IlmBase_INCLUDE_DIRS})
  257. elseif(NOT IlmBase_FOUND)
  258. message(FATAL_ERROR "IlmBase::Half can not be found!")
  259. endif()
  260. find_package(TBB REQUIRED COMPONENTS tbb)
  261. find_package(ZLIB REQUIRED)
  262. find_package(Boost REQUIRED COMPONENTS iostreams system)
  263. # Use GetPrerequisites to see which libraries this OpenVDB lib has linked to
  264. # which we can query for optional deps. This basically runs ldd/otoll/objdump
  265. # etc to track deps. We could use a vdb_config binary tools here to improve
  266. # this process
  267. include(GetPrerequisites)
  268. set(_EXCLUDE_SYSTEM_PREREQUISITES 1)
  269. set(_RECURSE_PREREQUISITES 0)
  270. set(_OPENVDB_PREREQUISITE_LIST)
  271. if(NOT OPENVDB_USE_STATIC_LIBS)
  272. get_prerequisites(${OpenVDB_openvdb_LIBRARY}
  273. _OPENVDB_PREREQUISITE_LIST
  274. ${_EXCLUDE_SYSTEM_PREREQUISITES}
  275. ${_RECURSE_PREREQUISITES}
  276. ""
  277. "${SYSTEM_LIBRARY_PATHS}"
  278. )
  279. endif()
  280. unset(_EXCLUDE_SYSTEM_PREREQUISITES)
  281. unset(_RECURSE_PREREQUISITES)
  282. # As the way we resolve optional libraries relies on library file names, use
  283. # the configuration options from the main CMakeLists.txt to allow users
  284. # to manually identify the requirements of OpenVDB builds if they know them.
  285. set(OpenVDB_USES_BLOSC ${USE_BLOSC})
  286. set(OpenVDB_USES_LOG4CPLUS ${USE_LOG4CPLUS})
  287. set(OpenVDB_USES_ILM ${USE_EXR})
  288. set(OpenVDB_USES_EXR ${USE_EXR})
  289. # Search for optional dependencies
  290. foreach(PREREQUISITE ${_OPENVDB_PREREQUISITE_LIST})
  291. set(_HAS_DEP)
  292. get_filename_component(PREREQUISITE ${PREREQUISITE} NAME)
  293. string(FIND ${PREREQUISITE} "blosc" _HAS_DEP)
  294. if(NOT ${_HAS_DEP} EQUAL -1)
  295. set(OpenVDB_USES_BLOSC ON)
  296. endif()
  297. string(FIND ${PREREQUISITE} "log4cplus" _HAS_DEP)
  298. if(NOT ${_HAS_DEP} EQUAL -1)
  299. set(OpenVDB_USES_LOG4CPLUS ON)
  300. endif()
  301. string(FIND ${PREREQUISITE} "IlmImf" _HAS_DEP)
  302. if(NOT ${_HAS_DEP} EQUAL -1)
  303. set(OpenVDB_USES_ILM ON)
  304. endif()
  305. endforeach()
  306. unset(_OPENVDB_PREREQUISITE_LIST)
  307. unset(_HAS_DEP)
  308. if(OpenVDB_USES_BLOSC)
  309. find_package(Blosc )
  310. if(NOT Blosc_FOUND OR NOT TARGET Blosc::blosc)
  311. message(STATUS "find_package could not find Blosc. Using fallback blosc search...")
  312. find_path(Blosc_INCLUDE_DIR blosc.h)
  313. find_library(Blosc_LIBRARY NAMES blosc)
  314. if (Blosc_INCLUDE_DIR AND Blosc_LIBRARY)
  315. set(Blosc_FOUND TRUE)
  316. add_library(Blosc::blosc UNKNOWN IMPORTED)
  317. set_target_properties(Blosc::blosc PROPERTIES
  318. IMPORTED_LOCATION "${Blosc_LIBRARY}"
  319. INTERFACE_INCLUDE_DIRECTORIES ${Blosc_INCLUDE_DIR})
  320. elseif()
  321. message(FATAL_ERROR "Blosc library can not be found!")
  322. endif()
  323. endif()
  324. endif()
  325. if(OpenVDB_USES_LOG4CPLUS)
  326. find_package(Log4cplus REQUIRED)
  327. endif()
  328. if(OpenVDB_USES_ILM)
  329. find_package(IlmBase REQUIRED)
  330. endif()
  331. if(OpenVDB_USES_EXR)
  332. find_package(OpenEXR REQUIRED)
  333. endif()
  334. if(UNIX)
  335. find_package(Threads REQUIRED)
  336. endif()
  337. # Set deps. Note that the order here is important. If we're building against
  338. # Houdini 17.5 we must include OpenEXR and IlmBase deps first to ensure the
  339. # users chosen namespaced headers are correctly prioritized. Otherwise other
  340. # include paths from shared installs (including houdini) may pull in the wrong
  341. # headers
  342. set(_OPENVDB_VISIBLE_DEPENDENCIES
  343. Boost::iostreams
  344. Boost::system
  345. IlmBase::Half
  346. )
  347. set(_OPENVDB_DEFINITIONS)
  348. if(OpenVDB_ABI)
  349. list(APPEND _OPENVDB_DEFINITIONS "-DOPENVDB_ABI_VERSION_NUMBER=${OpenVDB_ABI}")
  350. endif()
  351. if(OpenVDB_USES_EXR)
  352. list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES
  353. IlmBase::IlmThread
  354. IlmBase::Iex
  355. IlmBase::Imath
  356. OpenEXR::IlmImf
  357. )
  358. list(APPEND _OPENVDB_DEFINITIONS "-DOPENVDB_TOOLS_RAYTRACER_USE_EXR")
  359. endif()
  360. if(OpenVDB_USES_LOG4CPLUS)
  361. list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES Log4cplus::log4cplus)
  362. list(APPEND _OPENVDB_DEFINITIONS "-DOPENVDB_USE_LOG4CPLUS")
  363. endif()
  364. list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES
  365. TBB::tbb
  366. )
  367. if(UNIX)
  368. list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES
  369. Threads::Threads
  370. )
  371. endif()
  372. set(_OPENVDB_HIDDEN_DEPENDENCIES)
  373. if(OpenVDB_USES_BLOSC)
  374. if(OPENVDB_USE_STATIC_LIBS)
  375. list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES $<LINK_ONLY:Blosc::blosc>)
  376. else()
  377. list(APPEND _OPENVDB_HIDDEN_DEPENDENCIES Blosc::blosc)
  378. endif()
  379. endif()
  380. if(OPENVDB_USE_STATIC_LIBS)
  381. list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES $<LINK_ONLY:ZLIB::ZLIB>)
  382. else()
  383. list(APPEND _OPENVDB_HIDDEN_DEPENDENCIES ZLIB::ZLIB)
  384. endif()
  385. # ------------------------------------------------------------------------
  386. # Configure imported target
  387. # ------------------------------------------------------------------------
  388. set(OpenVDB_LIBRARIES
  389. ${OpenVDB_LIB_COMPONENTS}
  390. )
  391. set(OpenVDB_INCLUDE_DIRS ${OpenVDB_INCLUDE_DIR})
  392. set(OpenVDB_DEFINITIONS)
  393. list(APPEND OpenVDB_DEFINITIONS "${PC_OpenVDB_CFLAGS_OTHER}")
  394. list(APPEND OpenVDB_DEFINITIONS "${_OPENVDB_DEFINITIONS}")
  395. list(REMOVE_DUPLICATES OpenVDB_DEFINITIONS)
  396. set(OpenVDB_LIBRARY_DIRS "")
  397. foreach(LIB ${OpenVDB_LIB_COMPONENTS})
  398. get_filename_component(_OPENVDB_LIBDIR ${LIB} DIRECTORY)
  399. list(APPEND OpenVDB_LIBRARY_DIRS ${_OPENVDB_LIBDIR})
  400. endforeach()
  401. list(REMOVE_DUPLICATES OpenVDB_LIBRARY_DIRS)
  402. foreach(COMPONENT ${OpenVDB_FIND_COMPONENTS})
  403. if(NOT TARGET OpenVDB::${COMPONENT})
  404. add_library(OpenVDB::${COMPONENT} UNKNOWN IMPORTED)
  405. set_target_properties(OpenVDB::${COMPONENT} PROPERTIES
  406. INTERFACE_COMPILE_OPTIONS "${OpenVDB_DEFINITIONS}"
  407. INTERFACE_INCLUDE_DIRECTORIES "${OpenVDB_INCLUDE_DIR}"
  408. IMPORTED_LINK_DEPENDENT_LIBRARIES "${_OPENVDB_HIDDEN_DEPENDENCIES}" # non visible deps
  409. INTERFACE_LINK_LIBRARIES "${_OPENVDB_VISIBLE_DEPENDENCIES}" # visible deps (headers)
  410. INTERFACE_COMPILE_FEATURES cxx_std_11
  411. )
  412. if (_is_multi)
  413. set_target_properties(OpenVDB::${COMPONENT} PROPERTIES
  414. IMPORTED_LOCATION_RELEASE "${OpenVDB_${COMPONENT}_LIBRARY_RELEASE}"
  415. IMPORTED_LOCATION_DEBUG "${OpenVDB_${COMPONENT}_LIBRARY_DEBUG}"
  416. )
  417. else ()
  418. set_target_properties(OpenVDB::${COMPONENT} PROPERTIES
  419. IMPORTED_LOCATION "${OpenVDB_${COMPONENT}_LIBRARY}"
  420. )
  421. endif ()
  422. if (OPENVDB_USE_STATIC_LIBS)
  423. set_target_properties(OpenVDB::${COMPONENT} PROPERTIES
  424. INTERFACE_COMPILE_DEFINITIONS "OPENVDB_STATICLIB;OPENVDB_OPENEXR_STATICLIB"
  425. )
  426. endif()
  427. endif()
  428. endforeach()
  429. if(OpenVDB_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
  430. message(STATUS "OpenVDB libraries: ${OpenVDB_LIBRARIES}")
  431. endif()
  432. unset(_OPENVDB_DEFINITIONS)
  433. unset(_OPENVDB_VISIBLE_DEPENDENCIES)
  434. unset(_OPENVDB_HIDDEN_DEPENDENCIES)