cmake_minimum_required(VERSION 3.5)

project (TruckMonitorView)

set (CMAKE_CXX_STANDARD     11)


# Version.
set (MAJOR_VERSION "1")
set (MINOR_VERSION "1")
set (PATCH_VERSION "4")

# Import cmake modules.
list (APPEND    CMAKE_MODULE_PATH   "$ENV{HT_BUILDSYS_CMAKE_MODULES}")
include (HtCMakePub)

install_system_packages (
    PACKAGES    "nodejs"
    )

add_custom_command (
    OUTPUT              "${CMAKE_CURRENT_SOURCE_DIR}/dist"
    COMMAND             "npm" "install" "--force"
    COMMAND             "npm" "run" "build"
    WORKING_DIRECTORY   "${CMAKE_CURRENT_SOURCE_DIR}"
    )

add_custom_target ("${PROJECT_NAME}"    ALL
    DEPENDS     "${CMAKE_CURRENT_SOURCE_DIR}/dist"
    )
    
install(DIRECTORY       "${CMAKE_CURRENT_SOURCE_DIR}/dist"
    DESTINATION         "/var/www/${PROJECT_NAME}"
    )
        
        
# Pack.
set (CPACK_PACKAGE_NAME                 "ht-${PROJECT_NAME}")
set (CPACK_PACKAGE_VERSION_MAJOR        "${MAJOR_VERSION}")
set (CPACK_PACKAGE_VERSION_MINOR        "${MINOR_VERSION}")
set (CPACK_PACKAGE_VERSION_PATCH        "${PATCH_VERSION}")

set (CPACK_PACKAGE_CONTACT              "Li Lingyan <lingyan.li@waytous.com>, Gao Xiaofan <xiaofan.gao@waytous.com>")
set (CPACK_DEBIAN_PACKAGE_DESCRIPTION   "webtruckview. Branch: ${GIT_BRANCH}. Commit: ${GIT_LAST_COMMIT}.")

include(HtCMakeDeb)
