# How to statically link external library by target\_link\_libraries()?

**URL:** https://discourse.cmake.org/t/how-to-statically-link-external-library-by-target-link-libraries/1718
**Category:** Code
**Tags:** os:linux
**Created:** [August 18, 2020, 2:49am UTC](https://discourse.cmake.org/t/how-to-statically-link-external-library-by-target-link-libraries/1718 "2020-08-18T02:49:08Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![yosukesan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@yosukesan](https://discourse.cmake.org/u/yosukesan)
#### Post date: [August 18, 2020, 5:35am UTC](https://discourse.cmake.org/t/how-to-statically-link-external-library-by-target-link-libraries/1718/2 "2020-08-18T05:35:13Z")

</div>

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

---

_[View the full topic](https://discourse.cmake.org/t/how-to-statically-link-external-library-by-target-link-libraries/1718)._
