# Unknown CMake command "python3\_add\_library".

**URL:** https://discourse.cmake.org/t/unknown-cmake-command-python3-add-library/7799
**Category:** Usage
**Created:** [March 30, 2023, 4:43pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-python3-add-library/7799 "2023-03-30T16:43:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [March 30, 2023, 4:43pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-python3-add-library/7799/1 "2023-03-30T16:43:26Z")

</div>

Hi,

In my CMakeLists for a Python wrapper, I’ve got:

```auto
find_package(Python3 REQUIRED)
add_subdirectory(<path to pybind 11 CMakeLists>)

```

When calling cmake I’ve got (on CMake 3.19+, same behaviour on Linux or windows)

CMake Error at …/third\_party/pybind11/tools/pybind11NewTools.cmake:189 (python3\_add\_library):  
Unknown CMake command “python3\_add\_library”.

I find numerous references to this error on the net but without solution.

Regards,  
A.  
I’ve just stumbled on [https://gitlab.kitware.com/cmake/cmake/-/issues/23133](https://gitlab.kitware.com/cmake/cmake/-/issues/23133)  
thus I replaced find\_package(Python3 REQUIRED) by

```auto
find_package(Python3 REQUIRED Development)
find_package(Python3 REQUIRED Interpreter)

```

which helped me going through the configuration and generation phase.  
But why is it needed to require both component, omitting component is not the same as requiring all of them?  
OK, from doc:  
_For calls where no components are specified, there is no single expected behavior and target packages should clearly define what occurs in such cases. Common arrangements include assuming it should find all components, no components or some well-defined subset of the available components._  
and in FindPython3 doc  
If no `COMPONENTS` are specified, `Interpreter` is assumed.

I leave the post though as I assume, from my google search, that other may have the same issue and I hope that this may be of some help.

PS I’d like to mark my own post as solution but it seems to be forbidden 😋

---

<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: [March 30, 2023, 5:09pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-python3-add-library/7799/2 "2023-03-30T17:09:52Z")

</div>

Without components specified, only `Interpreter` is requested. Moreover, to ensure consistency between components, required all needed components at once (It is in the documentation):

```cmake
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)

```
