CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(TDengine)

SET(SHELL_BUILD_NAME "ts")
SET(SHELL_FINAL_NAME "taos")
SET(SHELL_CMD_NAME "taos_cmd")
SET(SHELL_TARGET_NAME "taos_target")

AUX_SOURCE_DIRECTORY(. SRC)
INCLUDE_DIRECTORIES(${PRJ_HEADER_PATH} ../inc ../../client/inc)

ADD_EXECUTABLE(${SHELL_BUILD_NAME} ${SRC})
TARGET_LINK_LIBRARIES(${SHELL_BUILD_NAME} taos_static trpc tutil pthread)

ADD_CUSTOM_COMMAND(OUTPUT ${SHELL_CMD_NAME}
  POST_BUILD
  COMMAND echo "rename file"
  DEPENDS ${SHELL_BUILD_NAME}
  COMMAND ${CMAKE_COMMAND} -E rename ${EXECUTABLE_OUTPUT_PATH}/${SHELL_BUILD_NAME} ${EXECUTABLE_OUTPUT_PATH}/${SHELL_FINAL_NAME}
  COMMENT "rename ts to taos")

ADD_CUSTOM_TARGET(${SHELL_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${SHELL_CMD_NAME})
