Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
1651c324
Commit
1651c324
authored
Jul 30, 2020
by
Henry Schreiner
Committed by
Henry Schreiner
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: address review points
parent
f64d5aa6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
23 deletions
+29
-23
.github/workflows/ci.yml
+3
-3
CMakeLists.txt
+23
-16
docs/compiling.rst
+2
-2
include/pybind11/detail/common.h
+1
-2
No files found.
.github/workflows/ci.yml
View file @
1651c324
...
@@ -106,10 +106,10 @@ jobs:
...
@@ -106,10 +106,10 @@ jobs:
run
:
cmake --build build -j 2
run
:
cmake --build build -j 2
-
name
:
Python tests C++11
-
name
:
Python tests C++11
run
:
cmake --build build --target pytest -j 2
-v
run
:
cmake --build build --target pytest -j 2
-
name
:
C++11 tests
-
name
:
C++11 tests
run
:
cmake --build build --target cpptest -j 2
-v
run
:
cmake --build build --target cpptest -j 2
-
name
:
Interface test C++11
-
name
:
Interface test C++11
run
:
cmake --build build --target test_cmake_build
run
:
cmake --build build --target test_cmake_build
...
@@ -125,7 +125,7 @@ jobs:
...
@@ -125,7 +125,7 @@ jobs:
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")
-
name
:
Build C++${{ matrix.max-cxx-std }}
-
name
:
Build C++${{ matrix.max-cxx-std }}
run
:
cmake --build build2 -j 2
-v
run
:
cmake --build build2 -j 2
-
name
:
Python tests C++${{ matrix.max-cxx-std }}
-
name
:
Python tests C++${{ matrix.max-cxx-std }}
run
:
cmake --build build2 --target pytest
run
:
cmake --build build2 --target pytest
...
...
CMakeLists.txt
View file @
1651c324
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
cmake_minimum_required
(
VERSION 3.7
)
cmake_minimum_required
(
VERSION 3.7
)
# VERSION 3.7...3.18, but some versions of VS have a patched CMake 3.11
# VERSION 3.7...3.18, but some versions of
MC
VS have a patched CMake 3.11
# that do not work properly with this syntax, so using the following workaround:
# that do not work properly with this syntax, so using the following workaround:
if
(
${
CMAKE_VERSION
}
VERSION_LESS 3.18
)
if
(
${
CMAKE_VERSION
}
VERSION_LESS 3.18
)
cmake_policy
(
VERSION
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
)
cmake_policy
(
VERSION
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
)
...
@@ -21,14 +21,19 @@ file(
...
@@ -21,14 +21,19 @@ file(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pybind11/detail/common.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pybind11/detail/common.h"
pybind11_version_defines
pybind11_version_defines
REGEX
REGEX
"#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH
|TYPE
) "
)
"#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) "
)
foreach
(
ver
${
pybind11_version_defines
}
)
foreach
(
ver
${
pybind11_version_defines
}
)
if
(
ver MATCHES
[
=[#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH|TYPE) +"?([^ ^"]+)"?$]=
]
)
if
(
ver MATCHES
[
[#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$]
]
)
set
(
PYBIND11_VERSION_
${
CMAKE_MATCH_1
}
"
${
CMAKE_MATCH_2
}
"
)
set
(
PYBIND11_VERSION_
${
CMAKE_MATCH_1
}
"
${
CMAKE_MATCH_2
}
"
)
endif
()
endif
()
endforeach
()
endforeach
()
if
(
PYBIND11_VERSION_PATCH MATCHES
[[([a-zA-Z]+)]]
)
set
(
PYBIND11_VERSION_TYPE
"
${
CMAKE_MATCH_1
}
"
)
endif
()
string
(
REGEX MATCH
"[0-9]+"
PYBIND11_VERSION_PATCH
"
${
PYBIND11_VERSION_PATCH
}
"
)
project
(
project
(
pybind11
pybind11
LANGUAGES
LANGUAGES
...
@@ -42,10 +47,11 @@ include(GNUInstallDirs)
...
@@ -42,10 +47,11 @@ include(GNUInstallDirs)
include
(
CMakePackageConfigHelpers
)
include
(
CMakePackageConfigHelpers
)
include
(
CMakeDependentOption
)
include
(
CMakeDependentOption
)
message
(
STATUS
"pybind11 v
${
pybind11_VERSION
}
${
PYBIND11_VERSION_TYPE
}
"
)
# Check if pybind11 is being used directly or via add_subdirectory
# Check if pybind11 is being used directly or via add_subdirectory
if
(
CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR
)
if
(
CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR
)
set
(
PYBIND11_MASTER_PROJECT ON
)
set
(
PYBIND11_MASTER_PROJECT ON
)
message
(
STATUS
"pybind11 v
${
pybind11_VERSION
}
${
PYBIND11_VERSION_TYPE
}
"
)
message
(
STATUS
"CMake
${
CMAKE_VERSION
}
"
)
message
(
STATUS
"CMake
${
CMAKE_VERSION
}
"
)
if
(
CMAKE_CXX_STANDARD
)
if
(
CMAKE_CXX_STANDARD
)
...
@@ -92,6 +98,9 @@ set(PYBIND11_HEADERS
...
@@ -92,6 +98,9 @@ set(PYBIND11_HEADERS
include/pybind11/stl.h
include/pybind11/stl.h
include/pybind11/stl_bind.h
include/pybind11/stl_bind.h
)
)
# TODO: compare with grep and warn if missmatched
# cmake 3.12 added list(TRANSFORM <list> PREPEND
# cmake 3.12 added list(TRANSFORM <list> PREPEND
# But we can't use it yet
# But we can't use it yet
string
(
REPLACE
"include/"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/"
string
(
REPLACE
"include/"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/"
...
@@ -125,6 +134,7 @@ endif()
...
@@ -125,6 +134,7 @@ endif()
# Note: when creating targets, you cannot use if statements at configure time -
# Note: when creating targets, you cannot use if statements at configure time -
# you need generator expressions, because those will be placed in the target file.
# you need generator expressions, because those will be placed in the target file.
# You can also place ifs *in* the Config.in, but not here.
# Build an interface library target:
# Build an interface library target:
add_library
(
pybind11 INTERFACE
)
add_library
(
pybind11 INTERFACE
)
...
@@ -139,21 +149,14 @@ if(CMAKE_VERSION VERSION_LESS 3.13)
...
@@ -139,21 +149,14 @@ if(CMAKE_VERSION VERSION_LESS 3.13)
target_compile_features
(
target_compile_features
(
pybind11
pybind11
INTERFACE
INTERFACE
cxx_auto_type
cxx_inheriting_constructors
cxx_constexpr
cxx_defaulted_functions
cxx_lambdas
cxx_nullptr
cxx_range_for
cxx_right_angle_brackets
cxx_strong_enums
cxx_user_literals
cxx_user_literals
cxx_
variadic_template
s
cxx_
right_angle_bracket
s
)
)
else
()
else
()
# This was added in CMake 3.8, but we are keeping a consistent breaking
# This was added in CMake 3.8, but we are keeping a consistent breaking
# point for the config file at 3.13. A config generated by CMake 3.13+
# point for the config file at 3.13. A config generated by CMake 3.13+
# can ony be read in 3.13+ due to the SHELL usage later, so this is safe to do.
# can on
l
y be read in 3.13+ due to the SHELL usage later, so this is safe to do.
target_compile_features
(
pybind11 INTERFACE cxx_std_11
)
target_compile_features
(
pybind11 INTERFACE cxx_std_11
)
endif
()
endif
()
...
@@ -170,13 +173,16 @@ if(CMAKE_VERSION VERSION_LESS 3.13)
...
@@ -170,13 +173,16 @@ if(CMAKE_VERSION VERSION_LESS 3.13)
target_link_libraries
(
module INTERFACE
"$<$<PLATFORM_ID:Darwin>:-undefined dynamic_lookup>"
)
target_link_libraries
(
module INTERFACE
"$<$<PLATFORM_ID:Darwin>:-undefined dynamic_lookup>"
)
else
()
else
()
# SHELL (3.12+) forces this to remain together, and link_options was added in 3.13+
# SHELL (3.12+) forces this to remain together, and link_options was added in 3.13+
# This is safer, because you are ensured the deduplication pass in CMake will not consider
# these separate and remove one but not the other.
target_link_options
(
module INTERFACE
"$<$<PLATFORM_ID:Darwin>:SHELL:-undefined dynamic_lookup>"
)
target_link_options
(
module INTERFACE
"$<$<PLATFORM_ID:Darwin>:SHELL:-undefined dynamic_lookup>"
)
endif
()
endif
()
message
(
STATUS
"CXX Compiler version:
${
CMAKE_CXX_COMPILER_VERSION
}
"
)
# Workaround for Python 2.7 and C++17 (C++14 as a warning) incompatibility
# Workaround for Python 2.7 and C++17 (C++14 as a warning) incompatibility
# This adds the flags -Wno-register and -Wno-deprecated-register if the compiler
# is Clang 3.9+ or AppleClang and the compile language is CXX, or /wd5033 for MSVC (all languages,
# since MSVC didn't recognize COMPILE_LANGUAGE until CMake 3.11+).
set
(
clang_4plus
"$<AND:$<CXX_COMPILER_ID:Clang>,$<NOT:$<VERSION_LESS:$<CXX_COMPILER_VERSION>,3.9>>>"
)
set
(
clang_4plus
"$<AND:$<CXX_COMPILER_ID:Clang>,$<NOT:$<VERSION_LESS:$<CXX_COMPILER_VERSION>,3.9>>>"
)
set
(
no_register
"$<OR:
${
clang_4plus
}
,$<CXX_COMPILER_ID:AppleClang>>"
)
set
(
no_register
"$<OR:
${
clang_4plus
}
,$<CXX_COMPILER_ID:AppleClang>>"
)
set
(
cxx_no_register
"$<AND:$<COMPILE_LANGUAGE:CXX>,
${
no_register
}
>"
)
set
(
cxx_no_register
"$<AND:$<COMPILE_LANGUAGE:CXX>,
${
no_register
}
>"
)
...
@@ -214,6 +220,7 @@ if(PYBIND11_INSTALL)
...
@@ -214,6 +220,7 @@ if(PYBIND11_INSTALL)
set
(
CMAKE_SIZEOF_VOID_P
${
_PYBIND11_CMAKE_SIZEOF_VOID_P
}
)
set
(
CMAKE_SIZEOF_VOID_P
${
_PYBIND11_CMAKE_SIZEOF_VOID_P
}
)
else
()
else
()
# CMake 3.14+ natively supports header-only libraries
write_basic_package_version_file
(
write_basic_package_version_file
(
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
PROJECT_NAME
}
ConfigVersion.cmake
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
PROJECT_NAME
}
ConfigVersion.cmake
VERSION
VERSION
...
...
docs/compiling.rst
View file @
1651c324
...
@@ -97,7 +97,7 @@ Configuration variables
...
@@ -97,7 +97,7 @@ Configuration variables
-----------------------
-----------------------
By default, pybind11 will compile modules with the compiler default or the
By default, pybind11 will compile modules with the compiler default or the
minimum standard required by
PyB
ind11, whichever is higher. You can set the
minimum standard required by
pyb
ind11, whichever is higher. You can set the
standard explicitly with
standard explicitly with
`CMAKE_CXX_STANDARD <https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_STANDARD.html>`_:
`CMAKE_CXX_STANDARD <https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_STANDARD.html>`_:
...
@@ -124,7 +124,7 @@ For example:
...
@@ -124,7 +124,7 @@ For example:
# Another method:
# Another method:
cmake -DPYTHON_EXECUTABLE=/path/to/python ..
cmake -DPYTHON_EXECUTABLE=/path/to/python ..
#
You will often see this idiom
:
#
This often is a good way to get the current Python, works in environments
:
cmake -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") ..
cmake -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") ..
find_package vs. add_subdirectory
find_package vs. add_subdirectory
...
...
include/pybind11/detail/common.h
View file @
1651c324
...
@@ -11,8 +11,7 @@
...
@@ -11,8 +11,7 @@
#define PYBIND11_VERSION_MAJOR 2
#define PYBIND11_VERSION_MAJOR 2
#define PYBIND11_VERSION_MINOR 6
#define PYBIND11_VERSION_MINOR 6
#define PYBIND11_VERSION_PATCH 0
#define PYBIND11_VERSION_PATCH dev0
#define PYBIND11_VERSION_TYPE "dev"
#define PYBIND11_NAMESPACE_BEGIN(name) namespace name {
#define PYBIND11_NAMESPACE_BEGIN(name) namespace name {
#define PYBIND11_NAMESPACE_END(name) }
#define PYBIND11_NAMESPACE_END(name) }
...
...
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