Skip to content

Commit 99cad87

Browse files
committed
[CMake] Explicitly set Android lib prefix/suffix
When compiling the Swift standard library for Android on Linux, the target prefixes and suffixes for static and shared libraries happen to be the same for both platforms. When using a macOS host to compile, however, the suffixes are different, causing build errors. Explicitly set the prefixes and suffixes to prevent errors when building on macOS.
1 parent 27fc4b0 commit 99cad87

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ function(_set_target_prefix_and_suffix target kind sdk)
5353
precondition(kind MESSAGE "kind is required")
5454
precondition(sdk MESSAGE "sdk is required")
5555

56-
if("${sdk}" STREQUAL "WINDOWS")
56+
if("${sdk}" STREQUAL "ANDROID")
57+
if("${kind}" STREQUAL "STATIC")
58+
set_property(TARGET "${target}" PROPERTY PREFIX "lib")
59+
set_property(TARGET "${target}" PROPERTY SUFFIX ".a")
60+
elseif("${libkind}" STREQUAL "SHARED")
61+
set_property(TARGET "${target}" PROPERTY PREFIX "lib")
62+
set_property(TARGET "${target}" PROPERTY SUFFIX ".so")
63+
endif()
64+
elseif("${sdk}" STREQUAL "WINDOWS")
5765
if("${kind}" STREQUAL "STATIC")
5866
set_property(TARGET "${target}" PROPERTY PREFIX "lib")
5967
set_property(TARGET "${target}" PROPERTY SUFFIX ".lib")

0 commit comments

Comments
 (0)