Skip to content

AddSwift.cmake's link_search_directories issues breaking Android compilation. #6488

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

Merged
merged 3 commits into from
Jan 7, 2017

Conversation

gonzalolarralde
Copy link
Contributor

When link_search_directories was added in 6ab6d3 a few issues on the implementation broken the compilation for Android (and potentially other platforms that require adding link search pats).

2 fixes and 1 small improvement are included in this PR. Please let me know if I should squash it or change anything.

@compnerd could you please review?

Thanks!

@@ -1109,7 +1110,7 @@ function(_add_swift_library_single target name)
COMPILE_FLAGS " ${c_compile_flags}")
set_property(TARGET "${target}" APPEND_STRING PROPERTY
LINK_FLAGS " ${link_flags}")
swift_target_link_search_directories(${target} ${library_search_directories})
swift_target_link_search_directories("${target}" "${library_search_directories}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why quote ${target}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw target quoted in multiple calls to add_dependencies, add_custom_command_target, add_library, _set_target_prefix_and_suffix, target_include_directories, set_target_properties among others. But you're right, there's no specific need for it as targets are not supposed to handle spaces, and multiple pieces of code lack of support of multi-target handling on the same call.

@@ -1165,8 +1166,7 @@ function(_add_swift_library_single target name)
"${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
swift_target_link_search_directories(${target_static}
${library_search_directories})
swift_target_link_search_directories("${target_static}" "${library_search_directories}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why quote the target here?

@@ -1870,8 +1875,7 @@ function(_add_swift_executable_single name)

set_property(TARGET ${name} APPEND_STRING PROPERTY
COMPILE_FLAGS " ${c_compile_flags}")
swift_target_link_search_directories(${name}
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
swift_target_link_search_directories("${name}" "${library_search_directories}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why quote the target?

@compnerd
Copy link
Member

@swift-ci please test and merge

@gonzalolarralde
Copy link
Contributor Author

@compnerd I made a mistake on my original contribution. I thought foreach wasn't iterating directories because semi-colons vs spaces, but the problem was actually STLD_FLAGS being overwritten instead of appended. Sorry about that. It is fixed in the last commit (0f37bdf).

@hpux735
Copy link
Contributor

hpux735 commented Dec 26, 2016

I tested this patch, builds for me

@compnerd
Copy link
Member

Can you drop the older commits in the set? This is fine as two changes: one to do the variable renaming (if it makes it clearer for others, then its probably worth it) and one to do the appending.

…earch directories.

`LIBRARY_SEARCH_DIRECTORIES` is actually being used as
`RESULT_VAR_NAME` to affect the value on the parent scope. In this
context `LIBRARY_SEARCH_DIRECTORIES_VAR_NAME` sounds like a better name.
…ecutable_single.

Linking directories from `_add_variant_link_flags` of were overwritten
in `_add_swift_executable_single` by not using the
`LIBRARY_SEARCH_DIRECTORIES` parameter.
…t directory.

STLD_FLAGS wasn't being appended, but replaced.
@gonzalolarralde
Copy link
Contributor Author

Sure. So, I actually made 3 changes. I made the changes you asked but kept the 3rd commit for adding using the output of LIBRARY_SEARCH_DIRECTORIES_VAR_NAME in _add_swift_executable_single. Makes sense?

@compnerd
Copy link
Member

compnerd commented Jan 7, 2017

@swift-ci please test and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants