set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")

file(GLOB_RECURSE ALL_SOURCES "src/*.c")

# Custom command to be executed before the build
add_custom_command(
    OUTPUT prebuild_command_done
    COMMAND cd "${SOURCE_DIR}" && xxd -i config.script > config_script.h
    COMMENT "Generating the config script"
    VERBATIM
)

# Custom target that depends on the custom command
add_custom_target(
    prebuild ALL
    DEPENDS prebuild_command_done
)

add_library(jtag_core ${ALL_SOURCES})
add_dependencies(jtag_core prebuild)

target_include_directories(jtag_core PUBLIC ${SOURCE_DIR})