Closed
Description
Issue description
Trying to use find_package in the cmake_example results in failure to find pybind11 headers when pybind11 is in /usr/local
The issue appears to be that the include path is set to /usr/local/include
rather than /usr/local/include/python3.5
Reproducible example code
This is on Ubuntu 16.04, with pybind11 2.2.1 installed via pip3.
pybind11 does know how to get the correct include paths:
python3 -c "import pybind11;print(pybind11.__file__)"
/usr/local/lib/python3.5/dist-packages/pybind11/__init__.py
python3 -m pybind11 --includes
-I/usr/include/python3.5m -I/usr/local/include/python3.5 -I/home/kevin/.local/include/python3.5m
Below is how I found the issue:
I cloned the cmake_example (non-recursively) and modified CMakeLists to read:
cmake_minimum_required(VERSION 2.8.12)
project(cmake_example)
find_package(pybind11)
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
pybind11_add_module(cmake_example src/main.cpp)
The output of cmake .
is below, and you can see that the INCLUDE_DIRS will cause a problem:
-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 5.4.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python3.5 (found version "3.5.2")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.5m.so
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Success
-- Performing Test HAS_CPP11_FLAG
-- Performing Test HAS_CPP11_FLAG - Success
-- Found pybind11 v2.1.dev0: /usr/local/include;/usr/include/python3.5m
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- LTO enabled
-- Configuring done
-- Generating done
The output of make VERBOSE=1
is:
[ 50%] Building CXX object CMakeFiles/cmake_example.dir/src/main.cpp.o
/usr/bin/c++ -Dcmake_example_EXPORTS -I/usr/local/include -I/usr/include/python3.5m -fPIC -std=c++14 -flto -fno-fat-lto-objects -o CMakeFiles/cmake_example.dir/src/main.cpp.o -c /home/kevin/src/cmake_example/src/main.cpp
/home/kevin/src/cmake_example/src/main.cpp:1:31: fatal error: pybind11/pybind11.h: No such file or directory