Unverified Commit e48b9e09 authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Skip extensions on python 2.7 (#848)

* Skip extensions on python 2.7

* Make macro instead of function

* Fix prefix and suffix for 2.7 lib
parent 0a9c18a5
...@@ -2,27 +2,36 @@ if(COMMAND find_python) ...@@ -2,27 +2,36 @@ if(COMMAND find_python)
return() return()
endif() endif()
macro(py_exec)
execute_process(${ARGN} RESULT_VARIABLE RESULT)
if(NOT RESULT EQUAL 0)
message(FATAL_ERROR "Process failed: ${ARGN}")
endif()
endmacro()
set(PYBIND11_NOPYTHON On) set(PYBIND11_NOPYTHON On)
find_package(pybind11 REQUIRED) find_package(pybind11 REQUIRED)
macro(find_python version) macro(find_python version)
find_program(PYTHON_CONFIG_${version} python${version}-config) find_program(PYTHON_CONFIG_${version} python${version}-config)
if(EXISTS ${PYTHON_CONFIG_${version}}) if(EXISTS ${PYTHON_CONFIG_${version}})
execute_process(COMMAND ${PYTHON_CONFIG_${version}} --includes OUTPUT_VARIABLE _python_include_args) py_exec(COMMAND ${PYTHON_CONFIG_${version}} --includes OUTPUT_VARIABLE _python_include_args)
separate_arguments(_python_includes UNIX_COMMAND "${_python_include_args}") separate_arguments(_python_includes UNIX_COMMAND "${_python_include_args}")
string(REPLACE "-I" "" _python_includes "${_python_includes}") string(REPLACE "-I" "" _python_includes "${_python_includes}")
add_library(python${version}::headers INTERFACE IMPORTED GLOBAL) add_library(python${version}::headers INTERFACE IMPORTED GLOBAL)
set_target_properties(python${version}::headers PROPERTIES set_target_properties(python${version}::headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_python_includes}" INTERFACE_INCLUDE_DIRECTORIES "${_python_includes}"
) )
execute_process(COMMAND ${PYTHON_CONFIG_${version}} --prefix OUTPUT_VARIABLE _python_prefix) py_exec(COMMAND ${PYTHON_CONFIG_${version}} --prefix OUTPUT_VARIABLE _python_prefix)
string(STRIP "${_python_prefix}" _python_prefix) string(STRIP "${_python_prefix}" _python_prefix)
set(PYTHON_${version}_EXECUTABLE "${_python_prefix}/bin/python${version}" CACHE PATH "") set(PYTHON_${version}_EXECUTABLE "${_python_prefix}/bin/python${version}" CACHE PATH "")
endif() endif()
endmacro() endmacro()
function(py_extension name version) function(py_extension name version)
set(_python_module_extension) set(_python_module_extension ".so")
execute_process(COMMAND ${PYTHON_CONFIG_${version}} --extension-suffix OUTPUT_VARIABLE _python_module_extension) if(version VERSION_GREATER_EQUAL 3.0)
string(STRIP "${_python_module_extension}" _python_module_extension) py_exec(COMMAND ${PYTHON_CONFIG_${version}} --extension-suffix OUTPUT_VARIABLE _python_module_extension)
string(STRIP "${_python_module_extension}" _python_module_extension)
endif()
set_target_properties(${name} PROPERTIES PREFIX "" SUFFIX "${_python_module_extension}") set_target_properties(${name} PROPERTIES PREFIX "" SUFFIX "${_python_module_extension}")
endfunction() endfunction()
function(py_add_module NAME) function(py_add_module NAME)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment