cmake_minimum_required(VERSION 3.15)

# For avoiding cmake define the  mcpu or march flags based on CMAKE_SYSTEM_PROCESSOR
cmake_policy(SET CMP0123 NEW)

project(ti_sdk)

#
# ${CMAKE_SOURCE_DIR} points to the path in which this file is present and can be used in downstream CMake files to refer files from root of SDK
#

include(cmake/ti_sdk.cmake)

ti_sdk_show_config()

# Note: Following ordering to add `ti_sdk_config` first is necessary since other targets may rely on some CMake properties set by the the config targets. e.g., the config target sets the
# `LINKER_SCRIPT_DEFAULT` property and the example CMake file invokes `get_target_property` with the config lib name. Hence if config lib is not yet added, CMake errors out `get_target_property()
# called with non-existent target`.
add_subdirectory(ti_sdk_config)
add_subdirectory(source)

# This include file is valid only in TI developer environment
if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/ti_sdk_internal.cmake)
    include(${CMAKE_SOURCE_DIR}/cmake/ti_sdk_internal.cmake)
endif()

if(${TI_SDK_INCLUDE_TEST_IN_PACKAGE})
    if(${TI_SDK_CMAKE_BUILD_EXE_TARGETS})
        add_subdirectory(test)
    endif()
endif()

if(${TI_SDK_CMAKE_BUILD_EXE_TARGETS})
    add_subdirectory(examples)
    if(EXISTS ${CMAKE_SOURCE_DIR}/solutions/)
        add_subdirectory(solutions)
    endif()
endif()
