find_package(Poetry REQUIRED)
if (NOT EXISTS ${CMAKE_BINARY_DIR}/poetry.lock)
    file(COPY ${CMAKE_SOURCE_DIR}/pyproject.toml DESTINATION ${CMAKE_BINARY_DIR})
    poetry_install(DIR ${CMAKE_BINARY_DIR} OPTIONS "--no-root" "--no-dev")
elseif (${CMAKE_SOURCE_DIR}/pyproject.toml IS_NEWER_THAN ${CMAKE_BINARY_DIR}/poetry.lock)
    file(COPY ${CMAKE_SOURCE_DIR}/pyproject.toml DESTINATION ${CMAKE_BINARY_DIR})
    poetry_update(DIR ${CMAKE_BINARY_DIR} OPTIONS "--no-dev")
endif ()
watch(FILES ${CMAKE_SOURCE_DIR}/pyproject.toml)
