# Unknown CMake command "SWIG\_ADD\_LIBRARY"

**URL:** https://discourse.cmake.org/t/unknown-cmake-command-swig-add-library/1208
**Category:** Usage
**Tags:** os:linux
**Created:** [May 13, 2020, 2:28pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-swig-add-library/1208 "2020-05-13T14:28:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pmchozas](https://discourse.cmake.org/user_avatar/discourse.cmake.org/pmchozas/32/598_2.png) [@pmchozas](https://discourse.cmake.org/u/pmchozas)
#### Post date: [May 13, 2020, 2:28pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-swig-add-library/1208/1 "2020-05-13T14:28:04Z")

</div>

Hi, I’m trying to install a python3 library with cmake 3.17 and I get this error all the time.

CMake Error at CMakeLists.txt:12 (SWIG\_ADD\_LIBRARY):  
Unknown CMake command “SWIG\_ADD\_LIBRARY”.

I’ve seen that was a common error with previous versions, but 3.17 is the latest and I still get it.  
Do any of you know how to solve it? thanks!

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [May 13, 2020, 2:35pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-swig-add-library/1208/2 "2020-05-13T14:35:33Z")

</div>

This command is defined in module [UseSWIG](https://cmake.org/cmake/help/latest/module/UseSWIG.html) so it is required to include this module to enable `SWIG_ADD_LIBRARY()` definition. And `SWIG` must be searched before this inclusion (module [FindSWIG](https://cmake.org/cmake/help/latest/module/FindSWIG.html)). Here is the needed code:

```cmake
find_package (SWIG)
include (UseSWIG)

```

---

<div class="post-metadata">

### Author: ![pmchozas](https://discourse.cmake.org/user_avatar/discourse.cmake.org/pmchozas/32/598_2.png) [@pmchozas](https://discourse.cmake.org/u/pmchozas)
#### Post date: [May 13, 2020, 2:47pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-swig-add-library/1208/3 "2020-05-13T14:47:31Z")

</div>

many thanks!! that solved it!
