set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../config/")

file(GLOB_RECURSE ALL_SOURCES "*.c")

# Custom command to be executed before the build
add_custom_command(
    OUTPUT prebuild_command_done
    COMMAND cd "${CONFIG_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
)

include_directories(${DIR_MODULES})

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