CMakeLists.txt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. cmake_minimum_required(VERSION 3.15)
  2. project(TestRequiredArtifacts.Check LANGUAGES C)
  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 NOT Python3_LIBRARY_RELEASE STREQUAL required_library)
  32. message (FATAL_ERROR "Failed to use input variable Python3_LIBRARY")
  33. endif()
  34. if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include)
  35. message (FATAL_ERROR "Failed to use input variable Python3_INCLUDE_DIR")
  36. endif()
  37. if (CHECK_SABI_LIBRARY AND NOT Python3_SABI_LIBRARY_RELEASE STREQUAL required_sabi_library)
  38. message (FATAL_ERROR "Failed to use input variable Python3_SABI_LIBRARY")
  39. endif()