Skip to content

[CMake] Add library target prefix/suffix in func #5068

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
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
25 changes: 18 additions & 7 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ function(_compute_lto_flag option out_var)
endif()
endfunction()

function(_set_target_prefix_and_suffix target kind sdk)
precondition(target MESSAGE "target is required")
precondition(kind MESSAGE "kind is required")
precondition(sdk MESSAGE "sdk is required")

if("${sdk}" STREQUAL "WINDOWS")
if("${kind}" STREQUAL "STATIC")
set_property(TARGET "${target}" PROPERTY PREFIX "lib")
set_property(TARGET "${target}" PROPERTY SUFFIX ".lib")
elseif("${libkind}" STREQUAL "SHARED")
set_property(TARGET "${target}" PROPERTY PREFIX "")
set_property(TARGET "${target}" PROPERTY SUFFIX ".dll")
endif()
endif()
endfunction()

function(is_darwin_based_sdk sdk_name out_var)
if ("${sdk_name}" STREQUAL "OSX" OR
"${sdk_name}" STREQUAL "IOS" OR
Expand Down Expand Up @@ -689,6 +705,7 @@ function(_add_swift_library_single target name)
${SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS}
${SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES}
${SWIFT_SECTIONS_OBJECT_END})
_set_target_prefix_and_suffix("${target}" "${libkind}" "${SWIFTLIB_SINGLE_SDK}")

if(SWIFTLIB_SINGLE_TARGET_LIBRARY)
if(NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_ICU_UC_INCLUDE}" STREQUAL "")
Expand All @@ -702,13 +719,7 @@ function(_add_swift_library_single target name)
endif()

if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "WINDOWS")
if("${libkind}" STREQUAL "STATIC")
set_property(TARGET "${target}" PROPERTY PREFIX "lib")
set_property(TARGET "${target}" PROPERTY SUFFIX ".lib")
elseif("${libkind}" STREQUAL "SHARED")
set_property(TARGET "${target}" PROPERTY PREFIX "")
set_property(TARGET "${target}" PROPERTY SUFFIX ".dll")

if("${libkind}" STREQUAL "SHARED")
# Each dll has an associated .lib (import library); since we may be
# building on a non-DLL platform (not windows), create an imported target
# for the library which created implicitly by the dll.
Expand Down