Self solved. If there is more efficient way please reply.
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(pthread_task)
add_executable(pthread_task main.c)
add_library(libpthread STATIC IMPORTED)
set_target_properties(libpthread PROPERTIES IMPORTED_LOCATION /usr/lib/x86_64-linux-gnu/libpthread.a)
set_target_properties(libpthread PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/include)
target_link_libraries(pthread_task libpthread)
install(TARGETS pthread_task DESTINATION ${CMAKE_INSTALL_PREFIX})
-
Just for check
$ readelf -s ./pthread_task | grep pthread
34: 0000000000000000 0 FILE LOCAL DEFAULT ABS pthread_create.c
58: 00000000004010fe 14 FUNC LOCAL DEFAULT 6 __pthread_create_2_1.cold
205: 0000000000000000 0 FILE LOCAL DEFAULT ABS pthread_join.c
206: 0000000000000000 0 FILE LOCAL DEFAULT ABS pthread_join_common.c
208: 0000000000000000 0 FILE LOCAL DEFAULT ABS pthread_mutex_lock.c
: