Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
caa9d44c
Commit
caa9d44c
authored
Jan 17, 2016
by
Wenzel Jakob
Browse files
cmake: robustified search for python
parent
3faa3879
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
CMakeLists.txt
CMakeLists.txt
+12
-5
docs/cmake.rst
docs/cmake.rst
+9
-2
No files found.
CMakeLists.txt
View file @
caa9d44c
...
...
@@ -14,6 +14,8 @@ option(PYBIND11_INSTALL "Install pybind11 header files?" ON)
# Add a CMake parameter for choosing a desired Python version
set
(
PYBIND11_PYTHON_VERSION
""
CACHE STRING
"Python version to use for compiling the example application"
)
include
(
CheckCXXCompilerFlag
)
# Set a default build configuration if none is specified. 'MinSizeRel' produces the smallest binaries
if
(
NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES
)
message
(
STATUS
"Setting build type to 'MinSizeRel' as none was specified."
)
...
...
@@ -23,11 +25,16 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif
()
string
(
TOUPPER
"
${
CMAKE_BUILD_TYPE
}
"
U_CMAKE_BUILD_TYPE
)
set
(
Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6
)
find_package
(
PythonLibs
${
PYBIND11_PYTHON_VERSION
}
REQUIRED
)
find_package
(
PythonInterp
${
PYBIND11_PYTHON_VERSION
}
REQUIRED
)
include
(
CheckCXXCompilerFlag
)
set
(
Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7
)
if
(
NOT
${
PYBIND11_PYTHON_VERSION
}
STREQUAL
""
)
find_package
(
PythonLibs
${
PYBIND11_PYTHON_VERSION
}
EXACT
)
if
(
NOT PythonLibs_FOUND
)
find_package
(
PythonLibs
${
PYBIND11_PYTHON_VERSION
}
REQUIRED
)
endif
()
else
()
find_package
(
PythonLibs REQUIRED
)
endif
()
find_package
(
PythonInterp
${
PYTHONLIBS_VERSION_STRING
}
EXACT REQUIRED
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
OR CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
# Enable C++11 mode on C++ / Clang
...
...
docs/cmake.rst
View file @
caa9d44c
...
...
@@ -28,8 +28,15 @@ and that the pybind11 repository is located in a subdirectory named :file:`pybin
string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
# Try to autodetect Python (can be overridden manually if needed)
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6)
find_package(PythonLibs ${EXAMPLE_PYTHON_VERSION} REQUIRED)
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7)
if (NOT ${PYBIND11_PYTHON_VERSION} STREQUAL "")
find_package(PythonLibs ${PYBIND11_PYTHON_VERSION} EXACT REQUIRED)
else()
find_package(PythonLibs REQUIRED)
endif()
# Uncomment the following line if you will also require a matching Python interpreter
# find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} EXACT REQUIRED)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# Enable C++11 mode on C++ / Clang
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment