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
c3c27c42
Commit
c3c27c42
authored
May 28, 2016
by
Dean Moldovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make C++ standard configurable
parent
9fb50c56
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
CMakeLists.txt
+19
-12
No files found.
CMakeLists.txt
View file @
c3c27c42
...
@@ -21,12 +21,28 @@ option(PYBIND11_TEST "Build tests?" ${PYBIND11_MASTER_PROJECT})
...
@@ -21,12 +21,28 @@ option(PYBIND11_TEST "Build tests?" ${PYBIND11_MASTER_PROJECT})
# Add a CMake parameter for choosing a desired Python version
# 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"
)
set
(
PYBIND11_PYTHON_VERSION
""
CACHE STRING
"Python version to use for compiling the example application"
)
include
(
CheckCXXCompilerFlag
)
list
(
APPEND CMAKE_MODULE_PATH
"
${
CMAKE_CURRENT_LIST_DIR
}
/tools"
)
list
(
APPEND CMAKE_MODULE_PATH
"
${
CMAKE_CURRENT_LIST_DIR
}
/tools"
)
set
(
Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7
)
set
(
Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7
)
find_package
(
PythonLibsNew
${
PYBIND11_PYTHON_VERSION
}
REQUIRED
)
find_package
(
PythonLibsNew
${
PYBIND11_PYTHON_VERSION
}
REQUIRED
)
include
(
CheckCXXCompilerFlag
)
if
(
NOT MSVC AND NOT PYBIND11_CPP_STANDARD
)
check_cxx_compiler_flag
(
"-std=c++14"
HAS_CPP14_FLAG
)
check_cxx_compiler_flag
(
"-std=c++11"
HAS_CPP11_FLAG
)
if
(
HAS_CPP14_FLAG
)
set
(
PYBIND11_CPP_STANDARD -std=c++14
)
elseif
(
HAS_CPP11_FLAG
)
set
(
PYBIND11_CPP_STANDARD -std=c++11
)
else
()
message
(
FATAL_ERROR
"Unsupported compiler -- pybind11 requires C++11 support!"
)
endif
()
set
(
PYBIND11_CPP_STANDARD
${
PYBIND11_CPP_STANDARD
}
CACHE STRING
"C++ standard flag, e.g. -std=c++11 or -std=c++14. Defaults to latest available."
)
endif
()
# Cache variables so pybind11_add_module can be used in parent projects
# Cache variables so pybind11_add_module can be used in parent projects
set
(
PYBIND11_INCLUDE_DIR
"
${
CMAKE_CURRENT_LIST_DIR
}
/include"
CACHE INTERNAL
""
)
set
(
PYBIND11_INCLUDE_DIR
"
${
CMAKE_CURRENT_LIST_DIR
}
/include"
CACHE INTERNAL
""
)
set
(
PYTHON_INCLUDE_DIRS
${
PYTHON_INCLUDE_DIRS
}
CACHE INTERNAL
""
)
set
(
PYTHON_INCLUDE_DIRS
${
PYTHON_INCLUDE_DIRS
}
CACHE INTERNAL
""
)
...
@@ -67,16 +83,7 @@ function(pybind11_add_module target_name)
...
@@ -67,16 +83,7 @@ function(pybind11_add_module target_name)
if
(
NOT MSVC
)
if
(
NOT MSVC
)
# Make sure C++11/14 are enabled
# Make sure C++11/14 are enabled
check_cxx_compiler_flag
(
"-std=c++14"
HAS_CPP14_FLAG
)
target_compile_options
(
${
target_name
}
PUBLIC
${
PYBIND11_CPP_STANDARD
}
)
check_cxx_compiler_flag
(
"-std=c++11"
HAS_CPP11_FLAG
)
if
(
HAS_CPP14_FLAG
)
target_compile_options
(
${
target_name
}
PUBLIC
"-std=c++14"
)
elseif
(
HAS_CPP11_FLAG
)
target_compile_options
(
${
target_name
}
PUBLIC
"-std=c++11"
)
else
()
message
(
FATAL_ERROR
"Unsupported compiler -- pybind11 requires C++11 support!"
)
endif
()
# Enable link time optimization and set the default symbol
# Enable link time optimization and set the default symbol
# visibility to hidden (very important to obtain small binaries)
# visibility to hidden (very important to obtain small binaries)
...
...
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