@@ -28,41 +28,53 @@ add_library(vdb_tool_common INTERFACE)
2828# Optional components
2929option (BUILD_TEST "Build unit tests" OFF )
3030
31- option (VDB_TOOL_USE_NANO "Compile with NanoVDB support" ON )
32- option (VDB_TOOL_NANO_USE_ZIP "Compile NanoVDB with zip compression support. Requires VDB_TOOL_USE_NANO =ON to have effect" ON )
33- option (VDB_TOOL_NANO_USE_BLOSC "Compile NanoVDB with Blosc compression support. Requires VDB_TOOL_USE_NANO =ON to have effect" ON )
34- option (VDB_TOOL_USE_PNG "Compile with PNG support" OFF )
35- option (VDB_TOOL_USE_EXR "Compile with EXR support" OFF )
36- option (VDB_TOOL_USE_JPG "Compile with JPG support" OFF )
37- option (VDB_TOOL_USE_ABC "Compile with Alembic support" OFF )
38- option (VDB_TOOL_USE_ALL "Compile with all optional components" OFF )
39- if (VDB_TOOL_USE_ALL )
40- set (VDB_TOOL_USE_NANO ON )
41- set (VDB_TOOL_USE_PNG ON )
42- set (VDB_TOOL_USE_EXR ON )
43- set (VDB_TOOL_USE_JPG ON )
44- set (VDB_TOOL_USE_ABC ON )
31+ option (OPENVDB_TOOL_USE_NANO "Compile with NanoVDB support" OFF )
32+ option (OPENVDB_TOOL_NANO_USE_ZIP "Compile NanoVDB with zip compression support. Requires OPENVDB_TOOL_USE_NANO =ON to have effect" ON )
33+ option (OPENVDB_TOOL_NANO_USE_BLOSC "Compile NanoVDB with Blosc compression support. Requires OPENVDB_TOOL_USE_NANO =ON to have effect" ON )
34+ option (OPENVDB_TOOL_USE_PNG "Compile with PNG support" OFF )
35+ option (OPENVDB_TOOL_USE_EXR "Compile with EXR support" OFF )
36+ option (OPENVDB_TOOL_USE_JPG "Compile with JPG support" OFF )
37+ option (OPENVDB_TOOL_USE_ABC "Compile with Alembic support" OFF )
38+ option (OPENVDB_TOOL_USE_ALL "Compile with all optional components" OFF )
39+ if (OPENVDB_TOOL_USE_ALL )
40+ set (OPENVDB_TOOL_USE_NANO ON )
41+ set (OPENVDB_TOOL_USE_PNG ON )
42+ set (OPENVDB_TOOL_USE_EXR ON )
43+ set (OPENVDB_TOOL_USE_JPG ON )
44+ set (OPENVDB_TOOL_USE_ABC ON )
4545endif ()
4646
47- if (VDB_TOOL_USE_NANO )
48- add_compile_definitions ( "VDB_TOOL_USE_NANO" )
49- if (VDB_TOOL_NANO_USE_ZIP )
50- add_compile_definitions ( "NANOVDB_USE_ZIP" )
47+ if (OPENVDB_TOOL_USE_NANO )
48+ target_compile_definitions (vdb_tool_common INTERFACE "VDB_TOOL_USE_NANO" )
49+ if (OPENVDB_TOOL_NANO_USE_ZIP )
50+ target_compile_definitions (vdb_tool_common INTERFACE "NANOVDB_USE_ZIP" )
5151 find_package (ZLIB REQUIRED)
5252 target_link_libraries (vdb_tool_common INTERFACE ZLIB::ZLIB)
5353 endif ()
54- if (VDB_TOOL_NANO_USE_BLOSC )
55- add_compile_definitions ( "NANOVDB_USE_BLOSC" )
54+ if (OPENVDB_TOOL_NANO_USE_BLOSC )
55+ target_compile_definitions (vdb_tool_common INTERFACE "NANOVDB_USE_BLOSC" )
5656 find_package (Blosc REQUIRED)
5757 target_link_libraries (vdb_tool_common INTERFACE blosc)
5858 endif ()
59- if (OPENVDB_BUILD_NANOVDB)
60- target_include_directories (vdb_tool_common INTERFACE ../../nanovdb/)
59+ #target_include_directories(vdb_tool_common INTERFACE ${PROJECT_SOURCE_DIR}/../nanovdb/)
60+ if (NOT OPENVDB_BUILD_NANOVDB)
61+ find_package (OpenVDB COMPONENTS nanovdb)
62+ if (NOT OpenVDB_nanovdb_FOUND OR NOT OpenVDB_FOUND)
63+ message (FATAL_ERROR
64+ " Couldn't find NanoVDB\n "
65+ " Either set OPENVDB_CMAKE_PATH to <OpenVDB install path>/lib/cmake/OpenVDB"
66+ " or please pass -DUSE_NANOVDB=ON as a cmake argument." )
67+ endif ()
68+ set (NANOVDB_LIB OpenVDB::nanovdb)
69+ target_include_directories (vdb_tool_common INTERFACE ${OPENVDB_nanovdb_INCLUDE_DIR} )
70+ else ()
71+ set (NANOVDB_LIB nanovdb)
6172 endif ()
73+ target_link_libraries (vdb_tool_common INTERFACE ${NANOVDB_LIB} )
6274endif ()
6375
64- if (VDB_TOOL_USE_PNG )
65- add_compile_definitions ( "VDB_TOOL_USE_PNG" )
76+ if (OPENVDB_TOOL_USE_PNG )
77+ target_compile_definitions (vdb_tool_common INTERFACE "VDB_TOOL_USE_PNG" )
6678 if (WIN32 )
6779 find_package (libpng CONFIG REQUIRED)
6880 else ()
@@ -71,26 +83,26 @@ if(VDB_TOOL_USE_PNG)
7183 target_link_libraries (vdb_tool_common INTERFACE png)
7284endif ()
7385
74- if (VDB_TOOL_USE_JPG )
75- add_compile_definitions ( "VDB_TOOL_USE_JPG" )
86+ if (OPENVDB_TOOL_USE_JPG )
87+ target_compile_definitions (vdb_tool_common INTERFACE "VDB_TOOL_USE_JPG" )
7688 find_package (JPEG REQUIRED)
7789 target_link_libraries (vdb_tool_common INTERFACE ${JPEG_LIBRARIES} )
7890 target_include_directories (vdb_tool_common INTERFACE ${JPEG_INCLUDE_DIR} )
7991endif ()
8092
81- if (VDB_TOOL_USE_EXR )
82- add_compile_definitions ( "VDB_TOOL_USE_EXR" )
93+ if (OPENVDB_TOOL_USE_EXR )
94+ target_compile_definitions (vdb_tool_common INTERFACE "VDB_TOOL_USE_EXR" )
8395 find_package (OpenEXR REQUIRED)
8496 target_link_libraries (vdb_tool_common INTERFACE OpenEXR::IlmImf)
8597endif ()
8698
87- if (VDB_TOOL_USE_ABC )
88- add_compile_definitions ( "VDB_TOOL_USE_ABC" )
99+ if (OPENVDB_TOOL_USE_ABC )
100+ target_compile_definitions (vdb_tool_common INTERFACE "VDB_TOOL_USE_ABC" )
89101 find_package (Alembic CONFIG REQUIRED)
90102 target_link_libraries (vdb_tool_common INTERFACE Alembic::Alembic)
91103endif ()
92104
93- if (WIN32 AND (VDB_TOOL_USE_ALL OR (VDB_TOOL_USE_ABC AND VDB_TOOL_USE_EXR )))
105+ if (WIN32 AND (OPENVDB_TOOL_USE_ALL OR (OPENVDB_TOOL_USE_ABC AND OPENVDB_TOOL_USE_EXR )))
94106 message (WARNING
95107 " The OpenEXR and Alembic VCPKG packages are using conflicting Imath versions.\n "
96108 " Disable one, if you encounter unresolved external symbols" )
@@ -100,41 +112,41 @@ endif()
100112
101113# GCC flags
102114if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
103- add_compile_options ( -Wno-invalid-offsetof -pthread -lpthread)
104- add_compile_options ( "$<$<CONFIG:DEBUG>:-O1>" )
115+ target_compile_options (vdb_tool_common INTERFACE -Wno-invalid-offsetof -pthread -lpthread)
116+ target_compile_options (vdb_tool_common INTERFACE "$<$<CONFIG:DEBUG>:-O1>" )
105117endif ()
106118
107119
108120# MSVC flags
109121# Increase the number of sections that an object file can contain
110- add_compile_options ( "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/bigobj>" )
122+ target_compile_options (vdb_tool_common INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/bigobj>" )
111123# Excludes APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets
112- add_compile_definitions ( "$<$<CXX_COMPILER_ID:MSVC>:WIN32_LEAN_AND_MEAN>" )
124+ target_compile_definitions (vdb_tool_common INTERFACE "$<$<CXX_COMPILER_ID:MSVC>:WIN32_LEAN_AND_MEAN>" )
113125# Disable non-secure CRT library function warnings
114126# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/
115127# compiler-warning-level-3-c4996?view=vs-2019#unsafe-crt-library-functions
116- add_compile_definitions ( "$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>" )
128+ target_compile_definitions (vdb_tool_common INTERFACE "$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>" )
117129# Disable POSIX function name warnings
118130# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/
119131# compiler-warning-level-3-c4996?view=vs-2019#posix-function-names
120- add_compile_definitions ( "$<$<CXX_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_WARNINGS>" )
132+ target_compile_definitions (vdb_tool_common INTERFACE "$<$<CXX_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_WARNINGS>" )
121133
122134if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
123- add_compile_options ( "$<$<CONFIG:RELEASE>:/Oi>" )
135+ target_compile_options (vdb_tool_common INTERFACE "$<$<CONFIG:RELEASE>:/Oi>" )
124136
125137 message (STATUS "Suppressing some noisy MSVC CXX warnings." )
126138endif ()
127139# Conversion from int64_t to long
128- add_compile_options ( "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4244>" )
140+ target_compile_options (vdb_tool_common INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4244>" )
129141# It's not possible to use STL types in DLL interfaces in a portable and
130142# reliable way so disable this warning
131- add_compile_options ( "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4251>" )
143+ target_compile_options (vdb_tool_common INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4251>" )
132144# Conversion from size_t to uLong
133- add_compile_options ( "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4267>" )
145+ target_compile_options (vdb_tool_common INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4267>" )
134146# Non dll-interface class used as base for dll-interface class
135- #add_compile_options( "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4275>")
147+ #target_compile_options(vdb_tool_common INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4275>")
136148# Truncation from 'int' to 'bool'
137- #add_compile_options( "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4305>")
149+ #target_compile_options(vdb_tool_common INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4305>")
138150
139151if (OPENVDB_BUILD_CORE)
140152 target_link_libraries (vdb_tool_common INTERFACE ${OPENVDB_BINARIES_DEPENDENT_LIBS} )
0 commit comments