RequiredArtifactsCheck.cmake 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. enable_language(C)
  2. include("${PYTHON_ARTIFACTS}")
  3. set (components)
  4. if (CHECK_INTERPRETER)
  5. set (required_interpreter "${Python3_EXECUTABLE}")
  6. list (APPEND components Interpreter)
  7. endif()
  8. if (CHECK_LIBRARY OR CHECK_INCLUDE)
  9. list (APPEND components Development)
  10. if (CHECK_LIBRARY)
  11. set (required_library "${Python3_LIBRARY}")
  12. endif()
  13. if (CHECK_INCLUDE)
  14. set (required_include "${Python3_INCLUDE_DIR}")
  15. endif()
  16. endif()
  17. if (CHECK_SABI_LIBRARY)
  18. list (APPEND components Development.SABIModule)
  19. set (required_sabi_library "${Python3_SABI_LIBRARY}")
  20. endif()
  21. find_package (Python3 COMPONENTS ${components})
  22. if (PYTHON_IS_FOUND AND NOT Python3_FOUND)
  23. message (FATAL_ERROR "Python3 unexpectedly not found")
  24. endif()
  25. if (NOT PYTHON_IS_FOUND AND Python3_FOUND)
  26. message (FATAL_ERROR "Python3 unexpectedly found")
  27. endif()
  28. if (CHECK_INTERPRETER AND NOT Python3_EXECUTABLE STREQUAL required_interpreter)
  29. message (FATAL_ERROR "Failed to use input variable Python3_EXECUTABLE")
  30. endif()
  31. if (CHECK_LIBRARY AND PYTHON_IS_FOUND AND
  32. (NOT Python3_LIBRARY_RELEASE STREQUAL PYTHON_LIBRARY_RELEASE
  33. OR (WIN32 AND NOT Python3_RUNTIME_LIBRARY_RELEASE STREQUAL PYTHON_RUNTIME_LIBRARY_RELEASE)
  34. OR (PYTHON_LIBRARY_DEBUG AND NOT Python3_LIBRARY_DEBUG STREQUAL PYTHON_LIBRARY_DEBUG)
  35. OR (WIN32 AND PYTHON_RUNTIME_LIBRARY_DEBUG AND NOT Python3_RUNTIME_LIBRARY_DEBUG STREQUAL PYTHON_RUNTIME_LIBRARY_DEBUG)))
  36. message (FATAL_ERROR "Failed to use input variable Python3_LIBRARY")
  37. endif()
  38. if (CHECK_LIBRARY AND NOT PYTHON_IS_FOUND AND
  39. NOT Python3_LIBRARY_RELEASE STREQUAL required_library)
  40. message (FATAL_ERROR "Failed to use input variable Python3_LIBRARY")
  41. endif()
  42. if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include)
  43. message (FATAL_ERROR "Failed to use input variable Python3_INCLUDE_DIR")
  44. endif()
  45. if (CHECK_SABI_LIBRARY AND PYTHON_IS_FOUND AND
  46. (NOT Python3_SABI_LIBRARY_RELEASE STREQUAL PYTHON_SABI_LIBRARY_RELEASE
  47. OR (WIN32 AND NOT Python3_RUNTIME_SABI_LIBRARY_RELEASE STREQUAL PYTHON_RUNTIME_SABI_LIBRARY_RELEASE)
  48. OR (PYTHON_SABI_LIBRARY_DEBUG AND NOT Python3_SABI_LIBRARY_DEBUG STREQUAL PYTHON_SABI_LIBRARY_DEBUG)
  49. OR (WIN32 AND PYTHON_RUNTIME_SABI_LIBRARY_DEBUG AND NOT Python3_RUNTIME_SABI_LIBRARY_DEBUG STREQUAL PYTHON_RUNTIME_SABI_LIBRARY_DEBUG)))
  50. message (FATAL_ERROR "Failed to use input variable Python3_SABI_LIBRARY")
  51. endif()
  52. if (CHECK_SABI_LIBRARY AND NOT PYTHON_IS_FOUND AND
  53. NOT Python3_SABI_LIBRARY_RELEASE STREQUAL required_sabi_library)
  54. message (FATAL_ERROR "Failed to use input variable Python3_SABI_LIBRARY")
  55. endif()