You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pybind11.cmake 2.3 kB

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