Cleanup: deduplicate OpenVDB library definitions/include/libs logic
authorBrecht Van Lommel <brecht@blender.org>
Wed, 26 Feb 2020 14:11:24 +0000 (15:11 +0100)
committerBrecht Van Lommel <brecht@blender.org>
Wed, 26 Feb 2020 17:13:14 +0000 (18:13 +0100)
This will more important when we start using OpenVDB in more modules.

CMakeLists.txt
build_files/cmake/platform/platform_win32.cmake
extern/mantaflow/CMakeLists.txt
intern/mantaflow/CMakeLists.txt
intern/openvdb/CMakeLists.txt

index 8c6a5de4aa7d8adfd937fcc027398a7b151a80f8..0116446454e940bed79757cd29798bd3e0c01221 100644 (file)
@@ -899,6 +899,28 @@ if(NOT WITH_SYSTEM_EIGEN3)
   set(EIGEN3_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/Eigen3)
 endif()
 
+if(WITH_OPENVDB)
+  list(APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB)
+
+  if(WITH_OPENVDB_3_ABI_COMPATIBLE)
+    list(APPEND OPENVDB_DEFINITIONS -DOPENVDB_3_ABI_COMPATIBLE)
+  endif()
+
+  list(APPEND OPENVDB_INCLUDE_DIRS
+    ${BOOST_INCLUDE_DIR}
+    ${TBB_INCLUDE_DIRS}
+    ${OPENEXR_INCLUDE_DIRS})
+
+  list(APPEND OPENVDB_LIBRARIES ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
+
+  if(WITH_OPENVDB_BLOSC)
+    list(APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB_BLOSC)
+    list(APPEND OPENVDB_LIBRARIES ${BLOSC_LIBRARIES} ${ZLIB_LIBRARIES})
+  endif()
+
+  list(APPEND OPENVDB_LIBRARIES ${BOOST_LIBRARIES} ${TBB_LIBRARIES})
+endif()
+
 #-----------------------------------------------------------------------------
 # Configure OpenGL.
 
index 0c1374af3480669b8af7b624331d7a72aa7bbc3d..c3d00d254254ff540005a7dda5919ead77720e8d 100644 (file)
@@ -504,7 +504,7 @@ if(WITH_OPENVDB)
   set(OPENVDB_LIBPATH ${OPENVDB}/lib)
   set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
   set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ${BLOSC_LIBRARIES})
-  set(OPENVDB_DEFINITIONS -DNOMINMAX)
+  set(OPENVDB_DEFINITIONS -DNOMINMAX -DOPENVDB_STATICLIB -D_USE_MATH_DEFINES)
 endif()
 
 if(WITH_OPENIMAGEDENOISE)
index 7486f123666129239e6acaafa714e5c015cdd1ab..95d46ae5a9b5ff80f81ae3f308dbddcfb0c88cce 100644 (file)
@@ -49,11 +49,6 @@ if(WITH_TBB)
   add_definitions(-DTBB=1)
 endif()
 
-if(WITH_OPENVDB)
-  add_definitions(-DOPENVDB=1)
-  add_definitions(-DOPENVDB_STATICLIB)
-endif()
-
 if(WIN32)
   add_definitions(-D_USE_MATH_DEFINES)
 endif()
@@ -83,23 +78,13 @@ if(WITH_TBB)
 endif()
 
 if(WITH_OPENVDB)
+  add_definitions(-DOPENVDB=1 ${OPENVDB_DEFINITIONS})
   list(APPEND INC_SYS
-    ${BOOST_INCLUDE_DIR}
-    ${OPENEXR_INCLUDE_DIRS}
     ${OPENVDB_INCLUDE_DIRS}
   )
   list(APPEND LIB
     ${OPENVDB_LIBRARIES}
-    ${OPENEXR_LIBRARIES}
-    ${ZLIB_LIBRARIES}
-    ${BOOST_LIBRARIES}
   )
-  if(WITH_OPENVDB_BLOSC)
-    list(APPEND LIB
-      ${BLOSC_LIBRARIES}
-      ${ZLIB_LIBRARIES}
-    )
-  endif()
 endif()
 
 set(SRC
index d9b64b3a19944df34e715af52b3751838f8e805a..1ca523ccc44038c21a5111ff064f19c10c612cd5 100644 (file)
@@ -27,7 +27,6 @@ add_definitions(-DWITH_FLUID=1)
 
 if(WITH_OPENVDB)
   add_definitions(-DOPENVDB=1)
-  add_definitions(-DOPENVDB_STATICLIB)
 else()
   add_definitions(-DOPENVDB=0)
 endif()
@@ -66,22 +65,11 @@ endif()
 
 if(WITH_OPENVDB)
   list(APPEND INC_SYS
-    ${BOOST_INCLUDE_DIR}
-    ${OPENEXR_INCLUDE_DIRS}
     ${OPENVDB_INCLUDE_DIRS}
   )
   list(APPEND LIB
     ${OPENVDB_LIBRARIES}
-    ${OPENEXR_LIBRARIES}
-    ${ZLIB_LIBRARIES}
-    ${BOOST_LIBRARIES}
   )
-  if(WITH_OPENVDB_BLOSC)
-    list(APPEND LIB
-      ${BLOSC_LIBRARIES}
-      ${ZLIB_LIBRARIES}
-    )
-  endif()
 endif()
 
 set(SRC
index a681d723b9c4f8c60f313d7e043f64b33f9d4e0c..2b7517a255c0f00950cdac002619790cdd408d1b 100644 (file)
@@ -35,28 +35,9 @@ set(LIB
 )
 
 if(WITH_OPENVDB)
-  add_definitions(
-    -DWITH_OPENVDB
-    ${OPENVDB_DEFINITIONS}
-  )
-
-  if(WIN32)
-    add_definitions(
-      -DOPENVDB_STATICLIB
-      -D_USE_MATH_DEFINES
-    )
-  endif()
-
-  if(WITH_OPENVDB_3_ABI_COMPATIBLE)
-    add_definitions(
-      -DOPENVDB_3_ABI_COMPATIBLE
-    )
-  endif()
+  add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
 
   list(APPEND INC_SYS
-    ${BOOST_INCLUDE_DIR}
-    ${TBB_INCLUDE_DIRS}
-    ${OPENEXR_INCLUDE_DIRS}
     ${OPENVDB_INCLUDE_DIRS}
   )
 
@@ -79,23 +60,6 @@ if(WITH_OPENVDB)
 
   list(APPEND LIB
     ${OPENVDB_LIBRARIES}
-    ${OPENEXR_LIBRARIES}
-    ${ZLIB_LIBRARIES}
-  )
-
-  if(WITH_OPENVDB_BLOSC)
-    add_definitions(
-      -DWITH_OPENVDB_BLOSC
-    )
-    list(APPEND LIB
-      ${BLOSC_LIBRARIES}
-      ${ZLIB_LIBRARIES}
-    )
-  endif()
-
-  list(APPEND LIB
-    ${BOOST_LIBRARIES}
-    ${TBB_LIBRARIES}
   )
 endif()