aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/tools/pybind11Common.cmake
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/pybind11/tools/pybind11Common.cmake')
-rw-r--r--3rdparty/pybind11/tools/pybind11Common.cmake86
1 files changed, 39 insertions, 47 deletions
diff --git a/3rdparty/pybind11/tools/pybind11Common.cmake b/3rdparty/pybind11/tools/pybind11Common.cmake
index 3c05c682..e1fb601a 100644
--- a/3rdparty/pybind11/tools/pybind11Common.cmake
+++ b/3rdparty/pybind11/tools/pybind11Common.cmake
@@ -8,7 +8,6 @@ Adds the following targets::
pybind11::lto - Link time optimizations (manual selection)
pybind11::thin_lto - Link time optimizations (manual selection)
pybind11::python_link_helper - Adds link to Python libraries
- pybind11::python2_no_register - Avoid warning/error with Python 2 + C++14/7
pybind11::windows_extras - MSVC bigobj and mp for building multithreaded
pybind11::opt_size - avoid optimizations that increase code size
@@ -20,6 +19,7 @@ Adds the following functions::
#]======================================================]
# CMake 3.10 has an include_guard command, but we can't use that yet
+# include_guard(global) (pre-CMake 3.10)
if(TARGET pybind11::lto)
return()
endif()
@@ -65,31 +65,6 @@ set_property(
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11)
-# ----------------------- no register ----------------------
-
-# 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+).
-
-add_library(pybind11::python2_no_register INTERFACE IMPORTED ${optional_global})
-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>>")
-
-if(MSVC AND CMAKE_VERSION VERSION_LESS 3.11)
- set(cxx_no_register "${no_register}")
-else()
- set(cxx_no_register "$<AND:$<COMPILE_LANGUAGE:CXX>,${no_register}>")
-endif()
-
-set(msvc "$<CXX_COMPILER_ID:MSVC>")
-
-set_property(
- TARGET pybind11::python2_no_register
- PROPERTY INTERFACE_COMPILE_OPTIONS
- "$<${cxx_no_register}:-Wno-register;-Wno-deprecated-register>" "$<${msvc}:/wd5033>")
-
# --------------------------- link helper ---------------------------
add_library(pybind11::python_link_helper IMPORTED INTERFACE ${optional_global})
@@ -115,28 +90,32 @@ endif()
add_library(pybind11::windows_extras IMPORTED INTERFACE ${optional_global})
-if(MSVC)
- # /MP enables multithreaded builds (relevant when there are many files), /bigobj is
- # needed for bigger binding projects due to the limit to 64k addressable sections
+if(MSVC) # That's also clang-cl
+ # /bigobj is needed for bigger binding projects due to the limit to 64k
+ # addressable sections
set_property(
TARGET pybind11::windows_extras
APPEND
- PROPERTY INTERFACE_COMPILE_OPTIONS /bigobj)
+ PROPERTY INTERFACE_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:CXX>:/bigobj>)
- if(CMAKE_VERSION VERSION_LESS 3.11)
- set_property(
- TARGET pybind11::windows_extras
- APPEND
- PROPERTY INTERFACE_COMPILE_OPTIONS $<$<NOT:$<CONFIG:Debug>>:/MP>)
- else()
- # Only set these options for C++ files. This is important so that, for
- # instance, projects that include other types of source files like CUDA
- # .cu files don't get these options propagated to nvcc since that would
- # cause the build to fail.
- set_property(
- TARGET pybind11::windows_extras
- APPEND
- PROPERTY INTERFACE_COMPILE_OPTIONS $<$<NOT:$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/MP>>)
+ # /MP enables multithreaded builds (relevant when there are many files) for MSVC
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # no Clang no Intel
+ if(CMAKE_VERSION VERSION_LESS 3.11)
+ set_property(
+ TARGET pybind11::windows_extras
+ APPEND
+ PROPERTY INTERFACE_COMPILE_OPTIONS $<$<NOT:$<CONFIG:Debug>>:/MP>)
+ else()
+ # Only set these options for C++ files. This is important so that, for
+ # instance, projects that include other types of source files like CUDA
+ # .cu files don't get these options propagated to nvcc since that would
+ # cause the build to fail.
+ set_property(
+ TARGET pybind11::windows_extras
+ APPEND
+ PROPERTY INTERFACE_COMPILE_OPTIONS
+ $<$<NOT:$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/MP>>)
+ endif()
endif()
endif()
@@ -298,23 +277,36 @@ function(_pybind11_return_if_cxx_and_linker_flags_work result cxxflags linkerfla
endfunction()
function(_pybind11_generate_lto target prefer_thin_lto)
+ if(MINGW)
+ message(STATUS "${target} disabled (problems with undefined symbols for MinGW for now)")
+ return()
+ endif()
+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(cxx_append "")
set(linker_append "")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE)
# Clang Gold plugin does not support -Os; append -O3 to MinSizeRel builds to override it
set(linker_append ";$<$<CONFIG:MinSizeRel>:-O3>")
- elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT MINGW)
set(cxx_append ";-fno-fat-lto-objects")
endif()
- if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND prefer_thin_lto)
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le" OR CMAKE_SYSTEM_PROCESSOR MATCHES "mips64")
+ set(NO_FLTO_ARCH TRUE)
+ else()
+ set(NO_FLTO_ARCH FALSE)
+ endif()
+
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
+ AND prefer_thin_lto
+ AND NOT NO_FLTO_ARCH)
_pybind11_return_if_cxx_and_linker_flags_work(
HAS_FLTO_THIN "-flto=thin${cxx_append}" "-flto=thin${linker_append}"
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
endif()
- if(NOT HAS_FLTO_THIN)
+ if(NOT HAS_FLTO_THIN AND NOT NO_FLTO_ARCH)
_pybind11_return_if_cxx_and_linker_flags_work(
HAS_FLTO "-flto${cxx_append}" "-flto${linker_append}" PYBIND11_LTO_CXX_FLAGS
PYBIND11_LTO_LINKER_FLAGS)