blender/intern/mantaflow/CMakeLists.txt
Ray Molenkamp 7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00

85 lines
1.6 KiB
CMake

# SPDX-FileCopyrightText: 2019 Blender Foundation
#
# SPDX-License-Identifier: GPL-2.0-or-later
add_definitions(-DWITH_FLUID=1)
if(WITH_OPENVDB)
add_definitions(-DOPENVDB=1)
else()
add_definitions(-DOPENVDB=0)
endif()
if(WIN32)
add_definitions(-D_USE_MATH_DEFINES)
endif()
if(WIN32)
# Some files in extern are being included which brings up a bunch of
# "unreferenced formal parameter" warnings.
# So restore warn C4100 (unreferenced formal parameter) back to w4
remove_cc_flag("/w34100")
endif()
set(INC
extern
intern/strings
../../source/blender/blenlib
)
# Python is always required
add_definitions(-DWITH_PYTHON)
set(INC_SYS
../../extern/mantaflow/helper/util
../../extern/mantaflow/helper/pwrapper
../../extern/mantaflow/preprocessed
../guardedalloc
${PYTHON_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
${OPENVDB_LIBRARIES}
)
endif()
set(SRC
intern/manta_python_API.cpp
intern/manta_fluid_API.cpp
intern/MANTA_main.cpp
extern/manta_python_API.h
extern/manta_fluid_API.h
intern/MANTA_main.h
intern/strings/fluid_script.h
intern/strings/smoke_script.h
intern/strings/liquid_script.h
)
set(LIB
PRIVATE bf::dna
extern_mantaflow
${PYTHON_LINKFLAGS}
${PYTHON_LIBRARIES}
${ZLIB_LIBRARIES}
)
blender_add_lib(bf_intern_mantaflow "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")