Skip to content

Commit 7fbbcbb

Browse files
committed
cmake(android): skip linking -lpthread on Android
On Android pthread symbols are provided by bionic libc; there is no separate libpthread. Adding -lpthread triggers a link error (-lpthread not found). Guard pthread linkage with (UNIX AND NOT ANDROID) and document the reason. Other UNIX platforms (Linux, *BSD) still link against pthread explicitly; no behavior change elsewhere.
1 parent 1d472a8 commit 7fbbcbb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
201201
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
202202
generate_export_header(${PROJECT_NAME} BASE_NAME CORO EXPORT_FILE_NAME include/coro/export.hpp)
203203

204-
if(UNIX)
204+
if(UNIX AND NOT ANDROID)
205+
# On Android, pthread is built into libc; there is no separate libpthread, so using -lpthread results in an error.
205206
target_link_libraries(${PROJECT_NAME} PUBLIC pthread)
206207
endif()
207208

0 commit comments

Comments
 (0)