CMakeLists.txt 684 B

12345678910111213141516171819202122
  1. cmake_minimum_required(VERSION 3.1)
  2. project(TestSOABI C)
  3. find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
  4. if (NOT Python3_FOUND)
  5. message (FATAL_ERROR "Fail to found Python 3")
  6. endif()
  7. if(NOT DEFINED Python3_SOABI)
  8. message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found")
  9. endif()
  10. if (Python3_Development_FOUND AND Python3_SOABI)
  11. Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c)
  12. target_compile_definitions (spam3 PRIVATE PYTHON3)
  13. get_property (suffix TARGET spam3 PROPERTY SUFFIX)
  14. if (NOT suffix MATCHES "^.${Python3_SOABI}")
  15. message(FATAL_ERROR "Module suffix do not include Python3_SOABI")
  16. endif()
  17. endif()