set(DNNDK_POSSIBLE_ROOT_DIRS
  "$ENV{SDKTARGETSYSROOT}"
)

MESSAGE(STATUS "DNNDK search path: ${DNNDK_POSSIBLE_ROOT_DIRS}")

set(DNNDK_INCDIR_SUFFIXES
  "/usr/include"
)

set(DNNDK_LIBDIR_SUFFIXES
  "/usr/lib"
)

find_path(DNNDK_INCDIR "dnndk/dnndk.h" PATHS ${DNNDK_POSSIBLE_ROOT_DIRS} PATH_SUFFIXES ${DNNDK_INCDIR_SUFFIXES} NO_CMAKE_FIND_ROOT_PATH)
find_path(DNNDK_INCDIR_N2CUBE "dnndk/n2cube.h" PATHS ${DNNDK_POSSIBLE_ROOT_DIRS} PATH_SUFFIXES ${DNNDK_INCDIR_SUFFIXES} NO_CMAKE_FIND_ROOT_PATH)

find_library(LIBDNNDK_N2CUBE_LIBRARY NAMES n2cube PATHS ${DNNDK_POSSIBLE_ROOT_DIRS} PATH_SUFFIXES ${DNNDK_LIBDIR_SUFFIXES} NO_CMAKE_FIND_ROOT_PATH)
find_library(LIBDNNDK_AOL_LIBRARY NAMES dpuaol PATHS ${DNNDK_POSSIBLE_ROOT_DIRS} PATH_SUFFIXES ${DNNDK_LIBDIR_SUFFIXES} NO_CMAKE_FIND_ROOT_PATH)
find_library(LIBDNNDK_HINEON_LIBRARY NAMES hineon PATHS ${DNNDK_POSSIBLE_ROOT_DIRS} PATH_SUFFIXES ${DNNDK_LIBDIR_SUFFIXES} NO_CMAKE_FIND_ROOT_PATH)

set(DNNDK_INCLUDE_DIR ${DNNDK_INCDIR} ${DNNDK_INCDIR_DPUTILS} ${DNNDK_INCDIR_N2CUBE})

if(EXISTS ${DNNDK_INCDIR} AND EXISTS ${DNNDK_INCDIR_N2CUBE})
  MESSAGE(STATUS "DNNDK and extensions found")
  set(DNNDK_FOUND ON)
else(EXISTS ${DNNDK_INCDIR} AND EXISTS ${DNNDK_INCDIR_N2CUBE})
  message(STATUS "DNNDK and extensions not found")
  set(DNNDK_FOUND OFF)
endif(EXISTS ${DNNDK_INCDIR} AND EXISTS ${DNNDK_INCDIR_N2CUBE})

set(DNNDK_INCLUDE_DIRS ${DNNDK_INCLUDE_DIR})
set(DNNDK_LIBS ${LIBDNNDK_AOL_LIBRARY} ${LIBDNNDK_N2CUBE_LIBRARY} ${LIBDNNDK_HINEON_LIBRARY})
message(STATUS "DNNDK_INCLUDE_DIRS = ${DNNDK_INCLUDE_DIRS}")
message(STATUS "DNNDK_LIBS         = ${DNNDK_LIBS}")
