# Copyright (C) 2023-2026, Texas Instruments Incorporated
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# *  Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# *  Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# *  Neither the name of Texas Instruments Incorporated nor the names of
#    its contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

cmake_minimum_required(VERSION 3.21.3)
include(CMakeSources.cmake)

project(edgeai LANGUAGES C ASM)
# Note: Required to import both TiUtils and TiUtilsJson for now
# Json should declare its own dependency, but currently does not
ti_init_package(NAMESPACE EDGEAI PACKAGE_NAME Component1 DEPENDS_ON TiUtils TiUtilsJson)

find_package(TiUtils)

# EdgeAI is available for both CM33 and CM4F architectures

# Add dependencies for all platforms
ti_add_package_dependency(DriverlibCC27XX)
ti_add_package_dependency(DriverlibCC13X2CC26X2)
ti_add_package_dependency(FeatExtract)

# Create library for m33f architecture (cc27xx, cc13x4)
# Note: The same m33f library works for both CC27XX and CC13X4 device families
# Device-specific driverlib is linked at the application level.
ti_add_library(
    edgeai_m33f
    SOURCES ${SOURCES_COMMON}
    # Set the name on disk to be edgeai.a. This function automatically places
    # the resulting library in lib/TOOLCHAIN/ARCH/edgeai.a
    OUTPUT_NAME edgeai
    # Explicitly set the architecture
    ARCH m33f
    # Specify the default compiler settings and other toolchain-related configurations
    LINK_PUBLIC CMakeCommon::${TI_TOOLCHAIN_NAME}_m33f TiUtils::json_m33f Driverlib::cc27xx
                FeatExtract::cmsis_dsp_m33f
    # Include the source/ folder of the current repository, and export it
    # as an include for downstream users who depend on this library
    ADD_SDK_INCLUDE_PATH source
)

# Create library for cc13x2 (cc1352) with m4f architecture
ti_add_library(
    edgeai_m4f
    SOURCES ${SOURCES_COMMON}
    # Set the name on disk to be edgeai.a. This function automatically places
    # the resulting library in lib/TOOLCHAIN/ARCH/edgeai.a
    OUTPUT_NAME edgeai
    # Explicitly set the architecture
    ARCH m4f
    # Specify the default compiler settings and other toolchain-related configurations
    LINK_PUBLIC CMakeCommon::${TI_TOOLCHAIN_NAME}_m4f TiUtils::json_m4f Driverlib::cc13x2
                FeatExtract::cmsis_dsp_m4f
    # Include the source/ folder of the current repository, and export it
    # as an include for downstream users who depend on this library
    ADD_SDK_INCLUDE_PATH source
)

ti_export_package()
