include(CMakeDependentOption)

STRING(TOLOWER ${QUL_PLATFORM} board_name)

IF(NOT DEFINED QUL_BOARD_SDK_DIR)
    message(FATAL_ERROR "Please define the QUL_BOARD_SDK_DIR CMake cache entry")
ENDIF()
message(STATUS "QUL_BOARD_SDK_DIR: " ${QUL_BOARD_SDK_DIR})

set(EA_COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common")

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/${board_name})

#if(NOT MIMXRT1170 AND NOT (${board_name} STREQUAL "mimxrt595-evk-freertos"))
#     target_sources(Platform PRIVATE
#         ${CMAKE_CURRENT_SOURCE_DIR}/common/platform_embeddedartists.cpp
#         ${CMAKE_CURRENT_SOURCE_DIR}/common/embeddedartists.c
#         ${CMAKE_CURRENT_SOURCE_DIR}/common/embeddedartists_qul.c
#         ${CMAKE_CURRENT_SOURCE_DIR}/common/ft5406_rt_async.c
#         ${PLATFORM_COMMON_SRC_DIR}/platform.cpp
#         ${PLATFORM_COMMON_SRC_DIR}/singlepointtoucheventdispatcher.cpp
#     )
#
#     target_include_directories(Platform PRIVATE
#         ${CMAKE_CURRENT_SOURCE_DIR}/common/
#         ${QUL_SRC_DIR}
#     )
#endif()

#target_sources(Platform PRIVATE
#    ${CMAKE_CURRENT_SOURCE_DIR}/common/nxp_sleep.cpp
#)

target_include_directories(Platform PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/common/
    ${QUL_SRC_DIR}
)

# Suppress some warnings for code that's in the SDKs
if(IAR)
    target_compile_options(Platform PRIVATE
        $<$<COMPILE_LANGUAGE:CXX>:--diag_suppress Pa082>
        $<$<COMPILE_LANGUAGE:C>:--diag_suppress Pa082>
    )
    #Pa082 order of volatile accesses is undefined
endif()
