ExactVersion.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. enable_language(C)
  2. find_package(${PYTHON} ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development)
  3. if(NOT ${PYTHON}_FOUND)
  4. message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}")
  5. endif()
  6. if(NOT ${PYTHON}_Interpreter_FOUND)
  7. message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter")
  8. endif()
  9. if(NOT ${PYTHON}_Development_FOUND)
  10. message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development")
  11. endif()
  12. if(NOT TARGET ${PYTHON}::Interpreter)
  13. message(SEND_ERROR "${PYTHON}::Interpreter not found")
  14. endif()
  15. if(NOT TARGET ${PYTHON}::Python)
  16. message(SEND_ERROR "${PYTHON}::Python not found")
  17. endif()
  18. if(NOT TARGET ${PYTHON}::Module)
  19. message(SEND_ERROR "${PYTHON}::Module not found")
  20. endif()
  21. # reset artifacts and second search with exact version already founded
  22. unset(${PYTHON}_EXECUTABLE)
  23. unset(_${PYTHON}_EXECUTABLE CACHE)
  24. unset(_${PYTHON}_LIBRARY_RELEASE CACHE)
  25. unset(_${PYTHON}_INCLUDE_DIR CACHE)
  26. set(Python_REQUESTED_VERSION ${${PYTHON}_VERSION})
  27. find_package(${PYTHON} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter Development)
  28. if(NOT ${PYTHON}_FOUND)
  29. message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}")
  30. endif()
  31. if(NOT ${PYTHON}_Interpreter_FOUND)
  32. message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter")
  33. endif()
  34. if(NOT ${PYTHON}_Development_FOUND)
  35. message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development")
  36. endif()
  37. if(NOT TARGET ${PYTHON}::Interpreter)
  38. message(SEND_ERROR "${PYTHON}::Interpreter not found")
  39. endif()
  40. if(NOT TARGET ${PYTHON}::Python)
  41. message(SEND_ERROR "${PYTHON}::Python not found")
  42. endif()
  43. if(NOT TARGET ${PYTHON}::Module)
  44. message(SEND_ERROR "${PYTHON}::Module not found")
  45. endif()