Changeset View
Changeset View
Standalone View
Standalone View
tests/gtests/runner/CMakeLists.txt
| Show All 34 Lines | |||||
| ) | ) | ||||
| setup_platform_linker_libs(blender_test) | setup_platform_linker_libs(blender_test) | ||||
| if(WIN32) | if(WIN32) | ||||
| foreach(_lib ${_test_libs}) | foreach(_lib ${_test_libs}) | ||||
| # Both target_link_libraries and target_link_options are required here | # Both target_link_libraries and target_link_options are required here | ||||
| # target_link_libraries will add any dependent libraries, while just setting | # target_link_libraries will add any dependent libraries, while just setting | ||||
| # the wholearchive flag in target link options will not. | # the wholearchive flag in target link options will not. | ||||
| target_link_libraries(blender_test ${_lib}) | target_link_libraries(blender_test PRIVATE ${_lib}) | ||||
| target_link_options(blender_test PRIVATE /wholearchive:$<TARGET_FILE:${_lib}>) | target_link_options(blender_test PRIVATE /wholearchive:$<TARGET_FILE:${_lib}>) | ||||
| endforeach() | endforeach() | ||||
| elseif(APPLE) | elseif(APPLE) | ||||
| # force_load for `_test_libs` ensures that all symbols definitely make it into the test binary. | # force_load for `_test_libs` ensures that all symbols definitely make it into the test binary. | ||||
| # But linking against them again using `target_link_libraries` creates duplicate symbol | # But linking against them again using `target_link_libraries` creates duplicate symbol | ||||
| # errors when linker cannot deduplicate a force loaded and linked library. | # errors when linker cannot deduplicate a force loaded and linked library. | ||||
| # So force load test libraries separately, and link against their non-"test libraries" | # So force load test libraries separately, and link against their non-"test libraries" | ||||
| # dependencies separately. | # dependencies separately. | ||||
| Show All 11 Lines | elseif(APPLE) | ||||
| # Force load test libraries. Ensure that they are not linked twice in case they | # Force load test libraries. Ensure that they are not linked twice in case they | ||||
| # are used as dependencies of other test libraries. | # are used as dependencies of other test libraries. | ||||
| foreach(_lib ${_test_libs}) | foreach(_lib ${_test_libs}) | ||||
| list(REMOVE_ITEM _test_libs_dependencies ${_lib}) | list(REMOVE_ITEM _test_libs_dependencies ${_lib}) | ||||
| add_dependencies(blender_test ${_lib}) | add_dependencies(blender_test ${_lib}) | ||||
| target_link_options(blender_test PRIVATE "LINKER:-force_load,$<TARGET_FILE:${_lib}>") | target_link_options(blender_test PRIVATE "LINKER:-force_load,$<TARGET_FILE:${_lib}>") | ||||
| endforeach() | endforeach() | ||||
| target_link_libraries(blender_test "${_test_libs_dependencies}") | target_link_libraries(blender_test PRIVATE "${_test_libs_dependencies}") | ||||
| unset(_test_libs_dependencies) | unset(_test_libs_dependencies) | ||||
| endif() | endif() | ||||
| unset(_test_libs) | unset(_test_libs) | ||||