Skip to content

link swift libraries when building test executables #270

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 1 commit into from
Jul 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ if(BSD_OVERLAY_FOUND)
${BSD_OVERLAY_LDFLAGS})
endif()

if(CMAKE_SWIFT_RUNTIME_LIBDIR)
target_link_libraries(bsdtestharness
PRIVATE
-L${CMAKE_SWIFT_RUNTIME_LIBDIR} -lswiftCore -lswiftSwiftOnoneSupport
-Wl,-rpath -Wl,${CMAKE_SWIFT_RUNTIME_LIBDIR})
Copy link
Member

Choose a reason for hiding this comment

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

Adding rpaths is discouraged. It can be used as a security issue to interposition other libraries. I think think that we should be trying to do this differently. Furthermore, the -l should not be added when doing the target_link_libraries as it will normally put the right prefix. Finally, -L should be handled via link_directories. Ill put up a PR to address some of this.

endif()

function(add_unit_test name)
set(options DISABLED_TEST)
set(single_value_args)
Expand Down Expand Up @@ -77,6 +84,12 @@ function(add_unit_test name)
PRIVATE
${BSD_OVERLAY_LDFLAGS})
endif()
if(CMAKE_SWIFT_RUNTIME_LIBDIR)
target_link_libraries(${name}
PRIVATE
-L${CMAKE_SWIFT_RUNTIME_LIBDIR} -lswiftCore -lswiftSwiftOnoneSupport
-Wl,-rpath -Wl,${CMAKE_SWIFT_RUNTIME_LIBDIR})
endif()
target_link_libraries(${name} PRIVATE bsdtests)
add_test(NAME ${name}
COMMAND bsdtestharness $<TARGET_FILE:${name}>)
Expand Down