psoc6_load_library(
  NAME emwin
  VERSION 5.48.1
)

set(EMWIN_INCLUDE_DIRS
  ${EMWIN_DIR}/GUI/Include
)
set(EMWIN_LINK_LIBRARIES
  mtb-pdl-cat1
)

if(HARDFP IN_LIST COMPONENTS)

  set(EMWIN_NOSTNS_SOURCES
    ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSNTS/GUIConf.h
  )
  set(EMWIN_NOSTNS_INCLUDE_DIRS
    ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSNTS
  )
  if(${TOOLCHAIN} STREQUAL GCC OR ${TOOLCHAIN} STREQUAL LLVM)
    set(EMWIN_NOSTNS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSNTS/TOOLCHAIN_GCC_ARM/libemWin_nosnts_cm4f_gcc.a
    )
  elseif(${TOOLCHAIN} STREQUAL ARM)
    set(EMWIN_NOSTNS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSNTS/TOOLCHAIN_ARM/libemWin_nosnts_cm4f_armc6.ar
    )
  elseif(${TOOLCHAIN} STREQUAL IAR)
    set(EMWIN_NOSTNS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSNTS/TOOLCHAIN_IAR/libemWin_nosnts_cm4f_iar.a
    )
  else()
    message(FATAL_ERROR "emwin: TOOLCHAIN ${TOOLCHAIN} is not supported.")
  endif()

  set(EMWIN_NOSTS_SOURCES
    ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSTS/GUIConf.h
  )
  set(EMWIN_NOSTS_INCLUDE_DIRS
    ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSTS
  )
  if(${TOOLCHAIN} STREQUAL GCC OR ${TOOLCHAIN} STREQUAL LLVM)
    set(EMWIN_NOSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSTS/TOOLCHAIN_GCC_ARM/libemWin_nosts_cm4f_gcc.a
    )
  elseif(${TOOLCHAIN} STREQUAL ARM)
    set(EMWIN_NOSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSTS/TOOLCHAIN_ARM/libemWin_nosts_cm4f_armc6.ar
    )
  elseif(${TOOLCHAIN} STREQUAL IAR)
    set(EMWIN_NOSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_NOSTS/TOOLCHAIN_IAR/libemWin_nosts_cm4f_iar.a
    )
  else()
    message(FATAL_ERROR "emwin: TOOLCHAIN ${TOOLCHAIN} is not supported.")
  endif()

  set(EMWIN_OSNTS_SOURCES
    ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSNTS/GUIConf.h
  )
  set(EMWIN_OSNTS_INCLUDE_DIRS
    ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSNTS
  )
  if(${TOOLCHAIN} STREQUAL GCC OR ${TOOLCHAIN} STREQUAL LLVM)
    set(EMWIN_OSNTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSNTS/TOOLCHAIN_GCC_ARM/libemWin_osnts_cm4f_gcc.a
    )
  elseif(${TOOLCHAIN} STREQUAL ARM)
    set(EMWIN_OSNTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSNTS/TOOLCHAIN_ARM/libemWin_osnts_cm4f_armc6.ar
    )
  elseif(${TOOLCHAIN} STREQUAL IAR)
    set(EMWIN_OSNTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSNTS/TOOLCHAIN_IAR/libemWin_osnts_cm4f_iar.a
    )
  else()
    message(FATAL_ERROR "emwin: TOOLCHAIN ${TOOLCHAIN} is not supported.")
  endif()

  set(EMWIN_OSTS_SOURCES
    ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSTS/GUIConf.h
  )
  set(EMWIN_OSTS_INCLUDE_DIRS
    ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSTS
  )
  if(${TOOLCHAIN} STREQUAL GCC OR ${TOOLCHAIN} STREQUAL LLVM)
    set(EMWIN_OSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSTS/TOOLCHAIN_GCC_ARM/libemWin_osts_cm4f_gcc.a
    )
  elseif(${TOOLCHAIN} STREQUAL ARM)
    set(EMWIN_OSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSTS/TOOLCHAIN_ARM/libemWin_osts_cm4f_armc6.ar
    )
  elseif(${TOOLCHAIN} STREQUAL IAR)
    set(EMWIN_OSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_HARDFP/COMPONENT_EMWIN_OSTS/TOOLCHAIN_IAR/libemWin_osts_cm4f_iar.a
    )
  else()
    message(FATAL_ERROR "emwin: TOOLCHAIN ${TOOLCHAIN} is not supported.")
  endif()

else() # SOFTFP or no FPU

  set(EMWIN_NOSTNS_SOURCES
    ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSNTS/GUIConf.h
  )
  set(EMWIN_NOSTNS_INCLUDE_DIRS
    ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSNTS
  )
  if(${TOOLCHAIN} STREQUAL GCC OR ${TOOLCHAIN} STREQUAL LLVM)
    set(EMWIN_NOSTNS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSNTS/TOOLCHAIN_GCC_ARM/libemWin_nosnts_gcc.a
    )
  elseif(${TOOLCHAIN} STREQUAL ARM)
    set(EMWIN_NOSTNS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSNTS/TOOLCHAIN_ARM/libemWin_nosnts_armc6.ar
    )
  elseif(${TOOLCHAIN} STREQUAL IAR)
    set(EMWIN_NOSTNS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSNTS/TOOLCHAIN_IAR/libemWin_nosnts_iar.a
    )
  else()
    message(FATAL_ERROR "emwin: TOOLCHAIN ${TOOLCHAIN} is not supported.")
  endif()

  set(EMWIN_NOSTS_SOURCES
    ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSTS/GUIConf.h
  )
  set(EMWIN_NOSTS_INCLUDE_DIRS
    ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSTS
  )
  if(${TOOLCHAIN} STREQUAL GCC OR ${TOOLCHAIN} STREQUAL LLVM)
    set(EMWIN_NOSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSTS/TOOLCHAIN_GCC_ARM/libemWin_nosts_gcc.a
    )
  elseif(${TOOLCHAIN} STREQUAL ARM)
    set(EMWIN_NOSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSTS/TOOLCHAIN_ARM/libemWin_nosts_armc6.ar
    )
  elseif(${TOOLCHAIN} STREQUAL IAR)
    set(EMWIN_NOSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_NOSTS/TOOLCHAIN_IAR/libemWin_nosts_iar.a
    )
  else()
    message(FATAL_ERROR "emwin: TOOLCHAIN ${TOOLCHAIN} is not supported.")
  endif()

  set(EMWIN_OSNTS_SOURCES
    ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSNTS/GUIConf.h
  )
  set(EMWIN_OSNTS_INCLUDE_DIRS
    ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSNTS
  )
  if(${TOOLCHAIN} STREQUAL GCC OR ${TOOLCHAIN} STREQUAL LLVM)
    set(EMWIN_OSNTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSNTS/TOOLCHAIN_GCC_ARM/libemWin_osnts_gcc.a
    )
  elseif(${TOOLCHAIN} STREQUAL ARM)
    set(EMWIN_OSNTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSNTS/TOOLCHAIN_ARM/libemWin_osnts_armc6.ar
    )
  elseif(${TOOLCHAIN} STREQUAL IAR)
    set(EMWIN_OSNTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSNTS/TOOLCHAIN_IAR/libemWin_osnts_iar.a
    )
  else()
    message(FATAL_ERROR "emwin: TOOLCHAIN ${TOOLCHAIN} is not supported.")
  endif()

  set(EMWIN_OSTS_SOURCES
    ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSTS/GUIConf.h
  )
  set(EMWIN_OSTS_INCLUDE_DIRS
    ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSTS
  )
  if(${TOOLCHAIN} STREQUAL GCC OR ${TOOLCHAIN} STREQUAL LLVM)
    set(EMWIN_OSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSTS/TOOLCHAIN_GCC_ARM/libemWin_osts_gcc.a
    )
  elseif(${TOOLCHAIN} STREQUAL ARM)
    set(EMWIN_OSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSTS/TOOLCHAIN_ARM/libemWin_osts_armc6.ar
    )
  elseif(${TOOLCHAIN} STREQUAL IAR)
    set(EMWIN_OSTS_LINK_LIBRARIES
      ${EMWIN_DIR}/GUI/COMPONENT_SOFTFP/COMPONENT_EMWIN_OSTS/TOOLCHAIN_IAR/libemWin_osts_iar.a
    )
  else()
    message(FATAL_ERROR "emwin: TOOLCHAIN ${TOOLCHAIN} is not supported.")
  endif()
endif()

add_library(emwin-nostns INTERFACE EXCLUDE_FROM_ALL)
target_sources(emwin-nostns INTERFACE
  ${EMWIN_NOSTNS_SOURCES}
)
target_include_directories(emwin-nostns INTERFACE
  ${EMWIN_INCLUDE_DIRS}
  ${EMWIN_NOSTNS_INCLUDE_DIRS}
)
target_compile_definitions(emwin-nostns INTERFACE
  COMPONENT_EMWIN_NOSTNS
)
target_link_libraries(emwin-nostns INTERFACE
  ${EMWIN_LINK_LIBRARIES}
  ${EMWIN_NOSTNS_LINK_LIBRARIES}
)

add_library(emwin-nosts INTERFACE EXCLUDE_FROM_ALL)
target_sources(emwin-nosts INTERFACE
  ${EMWIN_NOSTS_SOURCES}
)
target_include_directories(emwin-nosts INTERFACE
  ${EMWIN_INCLUDE_DIRS}
  ${EMWIN_NOSTS_INCLUDE_DIRS}
)
target_compile_definitions(emwin-nosts INTERFACE
  COMPONENT_EMWIN_NOSTS
)
target_link_libraries(emwin-nosts INTERFACE
  ${EMWIN_LINK_LIBRARIES}
  ${EMWIN_NOSTS_LINK_LIBRARIES}
)

add_library(emwin-osnts INTERFACE EXCLUDE_FROM_ALL)
target_sources(emwin-osnts INTERFACE
  ${EMWIN_OSNTS_SOURCES}
)
target_include_directories(emwin-osnts INTERFACE
  ${EMWIN_INCLUDE_DIRS}
  ${EMWIN_OSNTS_INCLUDE_DIRS}
)
target_compile_definitions(emwin-osnts INTERFACE
  COMPONENT_EMWIN_OSNTS
)
target_link_libraries(emwin-osnts INTERFACE
  ${EMWIN_LINK_LIBRARIES}
  ${EMWIN_OSNTS_LINK_LIBRARIES}
)

add_library(emwin-osts INTERFACE EXCLUDE_FROM_ALL)
target_sources(emwin-osts INTERFACE
  ${EMWIN_OSTS_SOURCES}
)
target_include_directories(emwin-osts INTERFACE
  ${EMWIN_INCLUDE_DIRS}
  ${EMWIN_OSTS_INCLUDE_DIRS}
)
target_compile_definitions(emwin-osts INTERFACE
  COMPONENT_EMWIN_OSTS
)
target_link_libraries(emwin-osts INTERFACE
  ${EMWIN_LINK_LIBRARIES}
  ${EMWIN_OSTS_LINK_LIBRARIES}
)
