Fix uninitialized-variables cmake warnings

This commit is contained in:
Nils Leif Fischer 2020-06-26 12:15:10 +02:00 committed by Wenzel Jakob
parent 3618807dca
commit 141e8cc0af
2 changed files with 35 additions and 8 deletions

View File

@ -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()

View File

@ -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,11 +216,13 @@ function(pybind11_add_module target_name)
endif() endif()
# Make sure C++11/14 are enabled # Make sure C++11/14 are enabled
if(PYBIND11_CPP_STANDARD)
if(CMAKE_VERSION VERSION_LESS 3.3) if(CMAKE_VERSION VERSION_LESS 3.3)
target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD}) target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD})
else() else()
target_compile_options(${target_name} PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${PYBIND11_CPP_STANDARD}>) target_compile_options(${target_name} PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${PYBIND11_CPP_STANDARD}>)
endif() endif()
endif()
if(ARG_NO_EXTRAS) if(ARG_NO_EXTRAS)
return() return()