include(FindPackageHandleStandardArgs)

find_program(YOSYS yosys PATHS "${YOSYS_ROOT_DIR}")
find_program(YOSYS_ABC yosys-abc PATHS "${YOSYS_ROOT_DIR}")
find_program(YOSYS_SMTBMC yosys-smtbmc PATHS "${YOSYS_ROOT_DIR}")

if (YOSYS)
    execute_process(COMMAND ${YOSYS} "-V" OUTPUT_VARIABLE YOSYS_VERSION_STRING)
    string(REGEX MATCH "^Yosys [0-9]+\.[0-9]+" YOSYS_VERSION "${YOSYS_VERSION_STRING}")
    string(REPLACE "Yosys " "" YOSYS_VERSION "${YOSYS_VERSION}")
endif()

find_package_handle_standard_args(YoSYs VERSION_VAR YOSYS_VERSION REQUIRED_VARS YOSYS)
