cmake_minimum_required(VERSION 3.13)

#
# Create Library and add Curent Library to project library list
#
# Create Library
cp_internal_library_register(ref_base 0)

#
#############################################################
#   Create static Library and add source code
# Create Library and add Curent Library to project library list
#############################################################
#
if(CONFIG_SUBSYS_CONFIG_CH)
    set(SRC_DIR src_ch)
else()
    set(SRC_DIR src)
endif()

set(SRCS
    "${SRC_DIR}/init_pm.c"
    "${SRC_DIR}/ref_outport_pm.c"
    "${SRC_DIR}/ref_param_pm.c"
    "${SRC_DIR}/run_mode_pm.c"
    "${SRC_DIR}/task_monitor_pm.c"
)
if(CONFIG_SUBSYS_CONFIG_CH)
    list(APPEND SRCS
        "${SRC_DIR}/event.c"
    )
else()
    list(APPEND SRCS
        "${SRC_DIR}/threadx_assert.c"
    )
endif()

if(CONFIG_MOCONF_CONSOLE_DEBUG)
    list(APPEND SRCS
        "${SRC_DIR}/ref_app_pm.c"
    )
endif()

if(CONFIG_SPRD_TIME_SYNC)
    list(APPEND SRCS
       "${SRC_DIR}/time_sync.c"
    )
endif()


if(CONFIG_MOCONF_POWER_DEBUG)
    list(APPEND SRCS
        "${SRC_DIR}/pwr_debug.c"
    )
endif()


if(CONFIG_MOCONF_REF_TEST)
    list(APPEND SRCS
        "${SRC_DIR}/test_simp.c"
    )
endif()

if(CONFIG_MOCONF_SLEEP_STAT)
    list(APPEND SRCS
        "${SRC_DIR}/sleep_stat.c"
    )

endif()

if(CONFIG_MOCONF_WDT_CTRL)
    list(APPEND SRCS
        "${SRC_DIR}/wd_ctrl_pm.c"
        "${SRC_DIR}/watchdog_feeder.c"
    )
endif()

#
#############################################################
# Add Internel depend header file
#############################################################
#
if(0)
cp_library_include_directories(
        ${PROJECT_SOURCE_ROOT}/Include
)
endif()

#
#############################################################
# Public curent header file to total project
# Add the directory to INTERFACE LIBRARY
#############################################################
#
if(CONFIG_SUBSYS_CONFIG_CH)
    cp_library_include_directories(
        ${PROJECT_SOURCE_ROOT}/chip_drv_ch/export/inc
        ${PROJECT_SOURCE_ROOT}/chip_drv_ch/chip_plf/${CONFIG_SOC_ID}/ch
        ${PROJECT_SOURCE_ROOT}/chip_drv_ch/chip_plf/${CONFIG_SOC_ID}/ch/module_glb
    )
else()
    cp_library_include_directories(
        ${PROJECT_SOURCE_ROOT}/chip_drv_pm/export/inc/outdated
        ${PROJECT_SOURCE_ROOT}/chip_drv_pm/export/inc
    )
endif()
cp_library_include_directories(
    ${PROJECT_SOURCE_ROOT}/ms_ref/export/inc
    ./inc
    ${PROJECT_SOURCE_ROOT}/ms_ref/source/sipc/inc
    ${PROJECT_SOURCE_ROOT}/ms_ref/source/base/inc/pwr_debug_cfg/${CONFIG_SOC_ID}
    ${PROJECT_SOURCE_ROOT}/ms_customize/export/inc
)
if(CONFIG_SENSOR_HUB_CODE_SELECT_SENSOR_HUB_SPRD)
    cp_library_include_directories(
        ${PROJECT_SOURCE_ROOT}/sensor_hub_sprd/public/source/common/HAL/HAL_HW/inc
        ${PROJECT_SOURCE_ROOT}/sensor_hub_sprd/public/source/common/protocol/inc
        ${PROJECT_SOURCE_ROOT}/sensor_hub_sprd/public/source/common/inc
        ${PROJECT_SOURCE_ROOT}/sensor_hub_sprd/public/system
    )
endif()

cp_library_include_directories(
    ./inc/pwr_debug_cfg/${CONFIG_SOC_ID}
)

if(CONFIG_SP_GNSS_ENABLE)
    cp_library_include_directories(
        ${PROJECT_SOURCE_ROOT}/fusion_location
    )
endif()

#
#############################################################
# Extenel Libriry that need to link
#
#############################################################
#
#cp_library_link_libraries()


#
#############################################################
# The defined flags that compile need use
#############################################################
#
#cp_library_compile_definitions(SOC_SHARKL5PRO)


#
#############################################################
# The compile option flags that need use
#############################################################
#
#cp_library_cc_option()

#
# Add source code to library
#
#cp_library_sources_ifdef(CONFIG_APP main.c)
cp_library_sources(${SRCS})
