CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
CMAKE_POLICY(VERSION 2.6)

FIND_PACKAGE(Torch REQUIRED)
FIND_PACKAGE(Qt4 REQUIRED)

INCLUDE_DIRECTORIES("${Torch_INSTALL_INCLUDE}/qtlua")
LINK_DIRECTORIES(${LUA_LIBDIR})
INCLUDE(${QT_USE_FILE})

SET(src qttorch.h qttorch.cpp)
SET(luasrc init.lua)

ADD_TORCH_PACKAGE(qttorch "${src}" "${luasrc}")

TARGET_LINK_LIBRARIES(qttorch luaT TH qtlua ${QT_LIBRARIES})
IF(LUALIB)
  TARGET_LINK_LIBRARIES(qttorch ${LUALIB})
ENDIF()

INSTALL(DIRECTORY "doc" DESTINATION "${Torch_INSTALL_LUA_PATH_SUBDIR}/qttorch")
