Skip to content

[BUG] FindPythonLibsNew.cmake will not search for the interpreter if find_package(Python ...) has already been invoked #2673

@xinyazhang

Description

@xinyazhang

Issue description

The following piece of CMake code will cause pybind11 to complain Python3 was found without the Interpreter component. Pybind11 requires this component.

find_package(Python3 COMPONENTS Development)
add_subdirectory(third-party/pybind11/)

This issue occurs in v2.6.1.
The problem can be resolved by adding Interpreter at the first line.
However the error message is confusing and the resolution only gets clear after reading the code of FindPythonLibsNew.cmake.

Reproducible example code

CMAKE_MINIMUM_REQUIRED(VERSION 3.12)

project(test CXX)
find_package(Python3 COMPONENTS Development)
add_subdirectory(third-party/pybind11/) # Requires v2.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions