Fix broken tests build in multi-binaries case.

When `WITH_TESTS_SINGLE_BINARY` is disabled, and `WITH_BUILDINFO` is
enabled, (most of) the generated tests binaries need to link buildinfo.

Pull Request: https://projects.blender.org/blender/blender/pulls/123734
This commit is contained in:
Bastien Montagne 2024-06-25 16:45:13 +02:00
parent 0081c4b64a
commit 73db631440

@ -346,19 +346,23 @@ function(blender_add_test_suite_executable
DISCOVER_TESTS FALSE
)
# Work-around run-time dynamic loader error
# symbol not found in flat namespace '_PyBaseObject_Type'
#
# Some tests are testing modules which are linked against Python, while some of unit
# tests might not use code path which uses Python functionality. In this case linker
# will optimize out all symbols from Python since it decides they are not used. This
# somehow conflicts with other libraries which are linked against the test binary and
# perform search of _PyBaseObject_Type on startup.
#
# Work-around by telling the linker that the python libraries should not be stripped.
if(APPLE)
target_link_libraries("${_test_name}_test" PRIVATE "-Wl,-force_load,${PYTHON_LIBRARIES}")
endif()
# Work-around run-time dynamic loader error
# symbol not found in flat namespace '_PyBaseObject_Type'
#
# Some tests are testing modules which are linked against Python, while some of unit
# tests might not use code path which uses Python functionality. In this case linker
# will optimize out all symbols from Python since it decides they are not used. This
# somehow conflicts with other libraries which are linked against the test binary and
# perform search of _PyBaseObject_Type on startup.
#
# Work-around by telling the linker that the python libraries should not be stripped.
if(APPLE)
target_link_libraries("${_test_name}_test" PRIVATE "-Wl,-force_load,${PYTHON_LIBRARIES}")
endif()
if(WITH_BUILDINFO)
target_link_libraries("${_test_name}_test" PRIVATE buildinfoobj)
endif()
endif()
endforeach()
endif()