set(LIB_NAME ${MCU_SERIES}_HAL_DRIVER)
string (TOLOWER ${MCU_SERIES}  MCU_SERIES)

if (NOT DEFINED HAL_DRIVER_CONFIG)
    message(WARNING "HAL_DRIVER_CONFIG not defined \r\n Project will be generate with default config. You can choose full path to configuration file ${MCU_SERIES}_hal_conf.h
filename should be - ${MCU_SERIES}_hal_conf.h" )
    message(WARNING "PROJECT WILL BE GENERATED WITH DEFAULT CONFIG" )
    if (NOT EXISTS default_config)
        file(MAKE_DIRECTORY default_config)
        endif()
    if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/default_config/${MCU_SERIES}_hal.h)
    file(COPY Inc/${MCU_SERIES}_hal_conf_template.h DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/default_config)
    file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/default_config/${MCU_SERIES}_hal_conf_template.h ${CMAKE_CURRENT_LIST_DIR}/default_config/${MCU_SERIES}_hal_conf.h )
    endif()
    set (${HAL_DRIVER_CONFIG} ${CMAKE_CURRENT_LIST_DIR}/default_config)
else()
    string(FIND ${HAL_DRIVER_CONFIG} ${MCU_SERIES}_hal_conf.h output REVERSE)
    string(SUBSTRING ${HAL_DRIVER_CONFIG} 0 ${output} output)
    set (HAL_DRIVER_CONFIG ${output})
endif()
project(${LIB_NAME}
        LANGUAGES C ASM
        )

add_definitions(-DUSE_HAL_DRIVER -D${MCU} -DUSE_FULL_LL_DRIVER)
file(GLOB_RECURSE SOURCES "Src/*.c")

add_library(${LIB_NAME} STATIC ${SOURCES})
add_library(${LIB_NAME}_INTERFACE INTERFACE)
if (GTEST)
    target_include_directories(${LIB_NAME}_INTERFACE INTERFACE Inc)
else()
    target_include_directories(${LIB_NAME} PUBLIC Inc ${HAL_DRIVER_CONFIG})
endif()
target_link_libraries(${LIB_NAME} PRIVATE CMSIS)
