option(USE_STABLE_ABI "Build with Python Stable ABI (abi3)" ON)

message("Python3_EXECUTABLE: ${Python3_EXECUTABLE}")
# manylinux don't contain Development, use Development.Module or Development.SABIModule:
# https://github.com/pybind/pybind11/pull/2689/files
if(USE_STABLE_ABI)
    find_package(Python3 REQUIRED COMPONENTS Interpreter Development.SABIModule)
    set(Python_SOABI "abi3")
    Python3_add_library(pyeep3 MODULE ./pyeep.c USE_SABI 3.9 WITH_SOABI)
else()
    find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
    Python3_add_library(pyeep3 MODULE ./pyeep.c WITH_SOABI)
    if(WIN32)
        target_link_libraries(pyeep3 PRIVATE Python3::Module)
    endif()
endif()
set_target_properties(pyeep3 PROPERTIES OUTPUT_NAME pyeep)
target_link_libraries(pyeep3 PRIVATE EepStatic)
install(TARGETS pyeep3 DESTINATION share/libeep/python3/libeep)

if(UNIX)
  set_target_properties(pyeep3 PROPERTIES PREFIX "")
endif()
if(WIN32)
  set_target_properties(pyeep3 PROPERTIES SUFFIX .pyd)
endif()
