function(tbp_add_pyx suffix)
    set(target_name "${suffix}")
    set(h_src "${target_name}.h")
    set(pyx_src "${target_name}.pyx")
    set(cxx_src "${target_name}.cxx")
    set(shared_src common.h hop_dict.h orbital_map.h)

    # Convert pyx to cxx
    add_custom_command(
        OUTPUT ${cxx_src}
        DEPENDS 
            ${CMAKE_CURRENT_SOURCE_DIR}/${h_src}
            ${CMAKE_CURRENT_SOURCE_DIR}/${pyx_src}
        VERBATIM
            COMMAND ${CYTHON}
            --cplus ${CMAKE_CURRENT_SOURCE_DIR}/${pyx_src}
            --output-file ${CMAKE_CURRENT_BINARY_DIR}/${cxx_src})
  
    # Create the python module
    python_add_library(
        ${target_name} MODULE
        ${CMAKE_CURRENT_SOURCE_DIR}/${h_src}
        ${CMAKE_CURRENT_BINARY_DIR}/${cxx_src}
        ${shared_src}
        WITH_SOABI)

    # Dependencies
    target_include_directories(${target_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
endfunction()

set(PYX_SUFFIX atom orbital_map sample super)
foreach(__module ${PYX_SUFFIX})
    tbp_add_pyx(${__module})
endforeach()

# ========================== Python interfaces ==========================
message(STATUS "")
message(STATUS "  Python builder interfaces to build:")

foreach(__module ${PYX_SUFFIX})
    message(STATUS "    " "${__module}")
endforeach()

message(STATUS "")

# install libraries
foreach(__module ${PYX_SUFFIX})
    install(TARGETS "${__module}"
        LIBRARY DESTINATION ${TBPLAS_LIB_INSTALL_PATH}
        DESTINATION ${TBPLAS_LIB_INSTALL_PATH})
endforeach()
