Fix: Excessive (re)builds of subprojects

Recent refactor external dependencies handling (D6642)
improperly linked all library dependencies with public
linkage rather than interface linkage. Causing excessive
(re)builds of subprojects when not needed.

This patch restores the interface linkage.

Reviewed By: brecht sergey

Differential Revision: https://developer.blender.org/D6983
This commit is contained in:
Ray Molenkamp
2020-03-02 12:42:01 -07:00
parent 409074aae5
commit 98c74c6a6e
2 changed files with 9 additions and 9 deletions

View File

@@ -122,7 +122,7 @@ function(target_link_libraries_optimized
)
foreach(_LIB ${LIBS})
target_link_libraries(${TARGET} optimized "${_LIB}")
target_link_libraries(${TARGET} INTERFACE optimized "${_LIB}")
endforeach()
endfunction()
@@ -132,7 +132,7 @@ function(target_link_libraries_debug
)
foreach(_LIB ${LIBS})
target_link_libraries(${TARGET} debug "${_LIB}")
target_link_libraries(${TARGET} INTERFACE debug "${_LIB}")
endforeach()
endfunction()
@@ -303,11 +303,11 @@ function(blender_add_lib__impl
set(next_library_mode "${library_lower}")
else()
if("${next_library_mode}" STREQUAL "optimized")
target_link_libraries(${name} optimized ${library})
target_link_libraries(${name} INTERFACE optimized ${library})
elseif("${next_library_mode}" STREQUAL "debug")
target_link_libraries(${name} debug ${library})
target_link_libraries(${name} INTERFACE debug ${library})
else()
target_link_libraries(${name} ${library})
target_link_libraries(${name} INTERFACE ${library})
endif()
set(next_library_mode "")
endif()

View File

@@ -97,13 +97,13 @@ endif()
# Source: https://github.com/PixarAnimationStudios/USD/blob/master/BUILDING.md#linking-whole-archives
if(WIN32)
target_link_libraries(bf_usd ${USD_LIBRARIES})
target_link_libraries(bf_usd INTERFACE ${USD_LIBRARIES})
elseif(CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(bf_usd "-Wl,--whole-archive ${USD_LIBRARIES} -Wl,--no-whole-archive ${TBB_LIBRARIES}")
target_link_libraries(bf_usd INTERFACE "-Wl,--whole-archive ${USD_LIBRARIES} -Wl,--no-whole-archive ${TBB_LIBRARIES}")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_link_libraries(bf_usd -Wl,-force_load ${USD_LIBRARIES})
target_link_libraries(bf_usd INTERFACE -Wl,-force_load ${USD_LIBRARIES})
else()
message(FATAL_ERROR "Unknown how to link USD with your compiler ${CMAKE_CXX_COMPILER_ID}")
endif()
target_link_libraries(bf_usd ${TBB_LIBRARIES})
target_link_libraries(bf_usd INTERFACE ${TBB_LIBRARIES})