-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to corrosion_link_libraries() #508
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1077,7 +1077,6 @@ function(corrosion_link_libraries target_name) | |
" aside from establishing a build dependency." | ||
) | ||
endif() | ||
add_dependencies(_cargo-build_${target_name} ${ARGN}) | ||
foreach(library ${ARGN}) | ||
set_property( | ||
TARGET _cargo-build_${target_name} | ||
|
@@ -1086,8 +1085,29 @@ function(corrosion_link_libraries target_name) | |
$<TARGET_PROPERTY:${library},LINKER_LANGUAGE> | ||
) | ||
|
||
corrosion_add_target_local_rustflags(${target_name} "-L$<TARGET_LINKER_FILE_DIR:${library}>") | ||
corrosion_add_target_local_rustflags(${target_name} "-l$<TARGET_LINKER_FILE_BASE_NAME:${library}>") | ||
if (TARGET ${library}) | ||
corrosion_add_target_local_rustflags(${target_name} | ||
"-L$<TARGET_LINKER_FILE_DIR:${library}>" | ||
"-l$<TARGET_LINKER_FILE_BASE_NAME:${library}>" | ||
) | ||
add_dependencies(_cargo-build_${target_name} ${library}) | ||
get_property(libs TARGET ${library} PROPERTY INTERFACE_LINK_LIBRARIES) | ||
corrosion_link_libraries(${target_name} ${libs}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a recursion check here? While ideally there would be no cyclic dependencies, I don't think that assumption holds in practice. The implementation could probably use something like this (not tested)
|
||
elseif(IS_ABSOLUTE ${library}) | ||
# Linking via full path | ||
corrosion_add_target_local_rustflags(${target_name} "-Clink-arg=${library}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add
|
||
else() | ||
# We have to assume ${library} is a non-CMake library name | ||
corrosion_add_target_local_rustflags(${target_name} "-l${library}") | ||
endif() | ||
|
||
# Propagate dependency on ${library} | ||
set_property( | ||
TARGET _cargo-build_${target_name} | ||
APPEND | ||
PROPERTY INTERFACE_LINK_LIBRARIES | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
${library} | ||
) | ||
endforeach() | ||
endfunction(corrosion_link_libraries) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INTERFACE_LINK_LIBRARIES
in CMake is evaluated at build time. This means simply reading this property here would cause us to miss any libraries that are added toINTERFACE_LINK_LIBRARIES
aftercorrosion_link_libraries()
.We could work around this by making a deferred function call for
TARGET
s, which reads the property at a later point in time.This is just a nit, it's not required for merging this PR.