CMake installation path consistency (#652)
* Add flag for installation of headers under python include directory
* Allow the disabling of distutils install_headers
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec104b0..63f3483 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,6 +92,11 @@
set(${PROJECT_NAME}_VERSION ${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH})
message(STATUS "pybind11 v${${PROJECT_NAME}_VERSION}")
+option (USE_PYTHON_INCLUDE_DIR "Install pybind11 headers in Python include directory instead of default installation prefix" OFF)
+if (USE_PYTHON_INCLUDE_DIR)
+ file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS})
+endif()
+
if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0
# Build an interface library target:
add_library(module INTERFACE)
diff --git a/setup.py b/setup.py
index a25f1af..f3011b0 100644
--- a/setup.py
+++ b/setup.py
@@ -4,18 +4,14 @@
from setuptools import setup
from pybind11 import __version__
+import os
-setup(
- name='pybind11',
- version=__version__,
- description='Seamless operability between C++11 and Python',
- author='Wenzel Jakob',
- author_email='wenzel.jakob@epfl.ch',
- url='https://github.com/wjakob/pybind11',
- download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__,
- packages=['pybind11'],
- license='BSD',
- headers=[
+# Prevent installation of pybind11 headers by setting
+# PYBIND11_USE_CMAKE.
+if os.environ.get('PYBIND11_USE_CMAKE'):
+ headers = []
+else:
+ headers = [
'include/pybind11/attr.h',
'include/pybind11/cast.h',
'include/pybind11/chrono.h',
@@ -33,7 +29,19 @@
'include/pybind11/stl.h',
'include/pybind11/stl_bind.h',
'include/pybind11/typeid.h'
- ],
+ ]
+
+setup(
+ name='pybind11',
+ version=__version__,
+ description='Seamless operability between C++11 and Python',
+ author='Wenzel Jakob',
+ author_email='wenzel.jakob@epfl.ch',
+ url='https://github.com/wjakob/pybind11',
+ download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__,
+ packages=['pybind11'],
+ license='BSD',
+ headers=headers,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',