mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
Fix uninitialized-variables cmake warnings
This commit is contained in:
parent
3618807dca
commit
141e8cc0af
@ -56,6 +56,9 @@ if(PYTHONLIBS_FOUND AND PYTHON_MODULE_EXTENSION)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Use the Python interpreter to find the libs.
|
# Use the Python interpreter to find the libs.
|
||||||
|
if(NOT PythonLibsNew_FIND_VERSION)
|
||||||
|
set(PythonLibsNew_FIND_VERSION "")
|
||||||
|
endif()
|
||||||
if(PythonLibsNew_FIND_REQUIRED)
|
if(PythonLibsNew_FIND_REQUIRED)
|
||||||
find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED)
|
find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED)
|
||||||
else()
|
else()
|
||||||
@ -192,11 +195,18 @@ MARK_AS_ADVANCED(
|
|||||||
# module.
|
# module.
|
||||||
SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
|
SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
|
||||||
SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
|
SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
|
||||||
|
if(NOT PYTHON_DEBUG_LIBRARY)
|
||||||
|
SET(PYTHON_DEBUG_LIBRARY "")
|
||||||
|
endif()
|
||||||
SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
|
SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
|
||||||
|
|
||||||
find_package_message(PYTHON
|
find_package_message(PYTHON
|
||||||
"Found PythonLibs: ${PYTHON_LIBRARY}"
|
"Found PythonLibs: ${PYTHON_LIBRARY}"
|
||||||
"${PYTHON_EXECUTABLE}${PYTHON_VERSION}")
|
"${PYTHON_EXECUTABLE}${PYTHON_VERSION_STRING}")
|
||||||
|
|
||||||
set(PYTHONLIBS_FOUND TRUE)
|
set(PYTHONLIBS_FOUND TRUE)
|
||||||
set(PythonLibsNew_FOUND TRUE)
|
set(PythonLibsNew_FOUND TRUE)
|
||||||
|
|
||||||
|
if(NOT PYTHON_MODULE_PREFIX)
|
||||||
|
SET(PYTHON_MODULE_PREFIX "")
|
||||||
|
endif()
|
||||||
|
@ -33,7 +33,7 @@ if(NOT CMAKE_VERSION VERSION_LESS 3.1)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Fall back to heuristics
|
# Fall back to heuristics
|
||||||
if(NOT PYBIND11_CPP_STANDARD AND NOT CMAKE_CXX_STANDARD)
|
if(NOT PYBIND11_CPP_STANDARD AND NOT CMAKE_CXX_STANDARD)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(PYBIND11_CPP_STANDARD /std:c++14)
|
set(PYBIND11_CPP_STANDARD /std:c++14)
|
||||||
@ -142,17 +142,32 @@ function(pybind11_add_module target_name)
|
|||||||
|
|
||||||
if(ARG_EXCLUDE_FROM_ALL)
|
if(ARG_EXCLUDE_FROM_ALL)
|
||||||
set(exclude_from_all EXCLUDE_FROM_ALL)
|
set(exclude_from_all EXCLUDE_FROM_ALL)
|
||||||
|
else()
|
||||||
|
set(exclude_from_all "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(${target_name} ${lib_type} ${exclude_from_all} ${ARG_UNPARSED_ARGUMENTS})
|
add_library(${target_name} ${lib_type} ${exclude_from_all} ${ARG_UNPARSED_ARGUMENTS})
|
||||||
|
|
||||||
if(ARG_SYSTEM)
|
if(ARG_SYSTEM)
|
||||||
set(inc_isystem SYSTEM)
|
set(inc_isystem SYSTEM)
|
||||||
|
else()
|
||||||
|
set(inc_isystem "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PYBIND11_INCLUDE_DIR_SELECTED "")
|
||||||
|
if(PYBIND11_INCLUDE_DIR)
|
||||||
|
# from project CMakeLists.txt
|
||||||
|
set(PYBIND11_INCLUDE_DIR_SELECTED ${PYBIND11_INCLUDE_DIR})
|
||||||
|
elseif(pybind11_INCLUDE_DIR)
|
||||||
|
# from pybind11Config
|
||||||
|
set(PYBIND11_INCLUDE_DIR_SELECTED ${pybind11_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
message(FATAL "No pybind11_INCLUDE_DIR available. Use "
|
||||||
|
"find_package(pybind11) before calling pybind11_add_module.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(${target_name} ${inc_isystem}
|
target_include_directories(${target_name} ${inc_isystem}
|
||||||
PRIVATE ${PYBIND11_INCLUDE_DIR} # from project CMakeLists.txt
|
PRIVATE ${PYBIND11_INCLUDE_DIR_SELECTED}
|
||||||
PRIVATE ${pybind11_INCLUDE_DIR} # from pybind11Config
|
|
||||||
PRIVATE ${PYTHON_INCLUDE_DIRS})
|
PRIVATE ${PYTHON_INCLUDE_DIRS})
|
||||||
|
|
||||||
# Python debug libraries expose slightly different objects
|
# Python debug libraries expose slightly different objects
|
||||||
@ -201,10 +216,12 @@ function(pybind11_add_module target_name)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Make sure C++11/14 are enabled
|
# Make sure C++11/14 are enabled
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.3)
|
if(PYBIND11_CPP_STANDARD)
|
||||||
target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD})
|
if(CMAKE_VERSION VERSION_LESS 3.3)
|
||||||
else()
|
target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD})
|
||||||
target_compile_options(${target_name} PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${PYBIND11_CPP_STANDARD}>)
|
else()
|
||||||
|
target_compile_options(${target_name} PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${PYBIND11_CPP_STANDARD}>)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARG_NO_EXTRAS)
|
if(ARG_NO_EXTRAS)
|
||||||
|
Loading…
Reference in New Issue
Block a user