1set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}) 2 3if(ENABLE_GITEE) 4 if(PYTHON_VERSION MATCHES "3.9") 5 set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz") 6 set(MD5 "a4a958127390e6e2ae4ff2fdcfa02113") 7 elseif(PYTHON_VERSION MATCHES "3.8") 8 set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz") 9 set(MD5 "a4a958127390e6e2ae4ff2fdcfa02113") 10 elseif(PYTHON_VERSION MATCHES "3.7") 11 set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.4.3.tar.gz") 12 set(MD5 "367868d51fa42088a3c77ae920eb4c81") 13 else() 14 message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'") 15 return() 16 endif() 17else() 18 if(PYTHON_VERSION MATCHES "3.9") 19 set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz") 20 set(MD5 "32a7811f3db423df4ebfc731a28e5901") 21 elseif(PYTHON_VERSION MATCHES "3.8") 22 set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz") 23 set(MD5 "32a7811f3db423df4ebfc731a28e5901") 24 elseif(PYTHON_VERSION MATCHES "3.7") 25 set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz") 26 set(MD5 "62254c40f89925bb894be421fe4cdef2") 27 else() 28 message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'") 29 return() 30 endif() 31endif() 32set(pybind11_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") 33set(pybind11_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") 34 35if(PYTHON_VERSION MATCHES "3.9") 36 mindspore_add_pkg(pybind11 37 VER 2.6.1 38 URL ${REQ_URL} 39 MD5 ${MD5} 40 CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE 41 ) 42elseif(PYTHON_VERSION MATCHES "3.8") 43 mindspore_add_pkg(pybind11 44 VER 2.6.1 45 URL ${REQ_URL} 46 MD5 ${MD5} 47 CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE 48 ) 49else() 50 mindspore_add_pkg(pybind11 51 VER 2.4.3 52 URL ${REQ_URL} 53 MD5 ${MD5} 54 CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE 55 ) 56endif() 57 58include_directories(${pybind11_INC}) 59find_package(pybind11 REQUIRED) 60set_property(TARGET pybind11::module PROPERTY IMPORTED_GLOBAL TRUE) 61add_library(mindspore::pybind11_module ALIAS pybind11::module) 62