if(NOT DEFINED akt_cmake_based_add_targets_in_included)
set(akt_cmake_based_add_targets_in_included)

include(${CMAKE_CURRENT_LIST_DIR}/set_all_imported_targets.cmake)

macro(akt_cmake_based_add_targets_in dir)
    akt_set_all_imported_targets()
    if(NOT DEFINED AKT_SRC_ROOT_DIR)
        set(AKT_SRC_ROOT_DIR "${CMAKE_SOURCE_DIR}/src")
    endif()
    akt_get_debugger(AKT_DEBUGGER)
    file(GLOB_RECURSE __cmake_files "${dir}/*.cmake")
    if(AKT_EXCLUDED_TARGETS)
        foreach(__cf ${AKT_EXCLUDED_TARGETS})
            list(REMOVE_ITEM __cmake_files ${__cf})
        endforeach()
    endif()
    foreach(__cf ${__cmake_files})
        akt_get_filename_component(__cf_no_ext ${__cf} NO_EXT)
        if(IS_DIRECTORY ${__cf_no_ext})
            akt_collect_srcs_and_targets(
                AKT_CHILD_SRCS AKT_CHILD_TARGETS ${__cf_no_ext}
            )
        else()
            set(AKT_CHILD_SRCS)
            set(AKT_CHILD_TARGETS)
        endif()
        foreach(src_ext "c" "cpp" "cc" "cxx")
            set(src_name ${__cf_no_ext}.${src_ext})
            if(EXISTS "${src_name}")
                # list(APPEND AKT_CHILD_SRCS ${src_name})
                set(AKT_SRC ${src_name})
            endif()
        endforeach()
        file(RELATIVE_PATH __rel_cmake ${AKT_SRC_ROOT_DIR} ${__cf})
        akt_target_name(AKT_TARGET "${__rel_cmake}")
        include(${__cf})
        unset(AKT_CHILD_SRCS)
        unset(AKT_CHILD_TARGETS)
        unset(AKT_TARGET)
        unset(AKT_SRC)
    endforeach()
    unset(AKT_DEBUGGER)
endmacro()

else()
endif()