Skip to content

Commit

Permalink
Fix link ordering errors with ld on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
nuudlman authored and Xaymar committed Oct 4, 2023
1 parent 2277c60 commit 0a05ad6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ function(streamfx_add_component COMPONENT_NAME)
set(COMPONENT_ALIAS "StreamFX::${COMPONENT_SANITIZED_NAME}")
set(COMPONENT_ALIAS "${COMPONENT_ALIAS}" PARENT_SCOPE)

streamfx_add_library(${COMPONENT_TARGET} OBJECT EXCLUDE_FROM_ALL)
streamfx_add_library(${COMPONENT_TARGET} STATIC EXCLUDE_FROM_ALL)
add_library(${COMPONENT_ALIAS} ALIAS ${COMPONENT_TARGET})
set_target_properties(${COMPONENT_TARGET} PROPERTIES
COMPONENT_LABEL "${COMPONENT_NAME}"
Expand All @@ -1059,10 +1059,7 @@ function(streamfx_add_component COMPONENT_NAME)
)

# Always depend on StreamFX::Core
target_link_libraries(${COMPONENT_TARGET}
PUBLIC
StreamFX_Core
)
target_link_libraries(${COMPONENT_TARGET} PRIVATE $<LINK_LIBRARY:WHOLE_ARCHIVE,StreamFX_Core>)

# Register the component globally.
get_target_property(_DEPENDS StreamFX COMPONENT_DEPENDS)
Expand Down Expand Up @@ -1540,7 +1537,6 @@ while(_UNRESOLVED)
endwhile()

#- Linking
target_link_libraries(StreamFX PUBLIC StreamFX_Core)
foreach(_ENTITY ${_RESOLVED})
set(RENTITY "StreamFX_${_ENTITY}")
get_target_property(_DEPENDS "${RENTITY}" COMPONENT_DEPENDS)
Expand All @@ -1555,18 +1551,20 @@ foreach(_ENTITY ${_RESOLVED})
if(T_CHECK)
target_link_libraries(${RENTITY}
PUBLIC
${RENTITY2}
$<LINK_LIBRARY:WHOLE_ARCHIVE,${RENTITY2}>
)
endif()
endforeach()
endif()

target_link_libraries(StreamFX
PRIVATE
${RENTITY}
$<LINK_LIBRARY:WHOLE_ARCHIVE,${RENTITY}>
)
endforeach()

target_link_libraries(StreamFX PUBLIC $<LINK_LIBRARY:WHOLE_ARCHIVE,StreamFX_Core>)

################################################################################
# Installation
################################################################################
Expand Down

0 comments on commit 0a05ad6

Please sign in to comment.