4a6aea35376cdd2eb314b8eb31894605ad29a18d
[platform/upstream/cmake.git] / Tests / FindPython / SOABI / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.1)
2
3 project(TestSOABI C)
4
5 find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
6 if (NOT Python3_FOUND)
7   message (FATAL_ERROR "Fail to found Python 3")
8 endif()
9
10 if(NOT DEFINED Python3_SOABI)
11   message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found")
12 endif()
13
14 if (Python3_Development_FOUND AND Python3_SOABI)
15   Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c)
16   target_compile_definitions (spam3 PRIVATE PYTHON3)
17
18   get_property (suffix TARGET spam3 PROPERTY SUFFIX)
19   if (NOT suffix MATCHES "^.${Python3_SOABI}")
20     message(FATAL_ERROR "Module suffix do not include Python3_SOABI")
21   endif()
22 endif()