psoc6_load_library(
  NAME wifi-connection-manager
  VERSION 2.0.3
)

set(WIFI_CONNECTION_MANAGER_SOURCES
  ${WIFI_CONNECTION_MANAGER_DIR}/include/cy_wcm.h
  ${WIFI_CONNECTION_MANAGER_DIR}/include/cy_wcm_error.h
  ${WIFI_CONNECTION_MANAGER_DIR}/include/cy_wcm_log.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_LWIP/cy_wcm.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_MBEDTLS/cy_wps_aes_ctr_ccm.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_MBEDTLS/cy_wps_crypto.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_MBEDTLS/cy_wps_crypto.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/cy_eapol.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/cy_wcm_wps.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/cy_wps.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/cy_wps_common.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/cy_wps_enrollee.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/nn.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/nn.c
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/cy_eapol.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/cy_template_wps_packets.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/cy_wps.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/cy_wps_common.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/cy_wps_constants.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/cy_wps_memory.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/cy_wps_result.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/cy_wps_structures.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include/wps_helper_utility.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/Utilities/TLV/tlv.h
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/Utilities/TLV/tlv.c
)
set(WIFI_CONNECTION_MANAGER_INCLUDE_DIRS
  ${WIFI_CONNECTION_MANAGER_DIR}
  ${WIFI_CONNECTION_MANAGER_DIR}/include
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_MBEDTLS
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/include
  ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_WPS/Utilities/TLV
)
set(WIFI_CONNECTION_MANAGER_LIBRARIES
  mtb-hal-cat1
  abstraction-rtos
  wifi-host-driver
  whd-bsp-integration
  lwip
  mbedtls
  connectivity-utilities
  wifi-mw-core
)

if(43012 IN_LIST COMPONENTS)
  list(APPEND WIFI_CONNECTION_MANAGER_SOURCES
    ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_43012/cy_chip_constants.h
  )
  list(APPEND WIFI_CONNECTION_MANAGER_INCLUDE_DIRS
    ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_43012
  )
elseif(43438 IN_LIST COMPONENTS)
  list(APPEND WIFI_CONNECTION_MANAGER_SOURCES
    ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_43438/cy_chip_constants.h
  )
  list(APPEND WIFI_CONNECTION_MANAGER_INCLUDE_DIRS
    ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_43438
  )
elseif(4343W IN_LIST COMPONENTS)
  list(APPEND WIFI_CONNECTION_MANAGER_SOURCES
    ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_4343W/cy_chip_constants.h
  )
  list(APPEND WIFI_CONNECTION_MANAGER_INCLUDE_DIRS
    ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_4343W
  )
elseif(4373 IN_LIST COMPONENTS)
  list(APPEND WIFI_CONNECTION_MANAGER_SOURCES
    ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_4373/cy_chip_constants.h
  )
  list(APPEND WIFI_CONNECTION_MANAGER_INCLUDE_DIRS
    ${WIFI_CONNECTION_MANAGER_DIR}/source/COMPONENT_4373
  )
else()
  message(FATAL_ERROR "wifi-connection-manager: COMPONENTS should include either 43012, 43438, 4343W or 4373.")
endif()

add_library(wifi-connection-manager STATIC EXCLUDE_FROM_ALL ${WIFI_CONNECTION_MANAGER_SOURCES})
target_include_directories(wifi-connection-manager PUBLIC ${WIFI_CONNECTION_MANAGER_INCLUDE_DIRS})
target_link_libraries(wifi-connection-manager PUBLIC ${WIFI_CONNECTION_MANAGER_LIBRARIES})
