提交 ac16f203 编写于 作者: F freemine

1. adjust CMakeLists.txt to enabling checking unixodbc existence

2. use install.sh to install odbcinst/odbc record in system
3. add packages (unixodbc/unixodbc-dev) to install in .travis.yml
上级 d33d693e
...@@ -32,6 +32,8 @@ matrix: ...@@ -32,6 +32,8 @@ matrix:
- python3-setuptools - python3-setuptools
- valgrind - valgrind
- psmisc - psmisc
- unixodbc
- unixodbc-dev
before_script: before_script:
- export TZ=Asia/Harbin - export TZ=Asia/Harbin
......
...@@ -21,5 +21,5 @@ ADD_SUBDIRECTORY(wal) ...@@ -21,5 +21,5 @@ ADD_SUBDIRECTORY(wal)
ADD_SUBDIRECTORY(cq) ADD_SUBDIRECTORY(cq)
ADD_SUBDIRECTORY(dnode) ADD_SUBDIRECTORY(dnode)
ADD_SUBDIRECTORY(connector/odbc) ADD_SUBDIRECTORY(connector/odbc)
# ADD_SUBDIRECTORY(connector/jdbc) ADD_SUBDIRECTORY(connector/jdbc)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
AUX_SOURCE_DIRECTORY(src SRC) IF (TD_LINUX_64)
find_program(HAVE_ODBCINST NAMES odbcinst)
# generate dynamic library (*.so) IF (HAVE_ODBCINST)
ADD_LIBRARY(todbc SHARED ${SRC}) include(CheckSymbolExists)
SET_TARGET_PROPERTIES(todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1) # shall we revert CMAKE_REQUIRED_LIBRARIES and how?
SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) set(CMAKE_REQUIRED_LIBRARIES odbc)
TARGET_LINK_LIBRARIES(todbc taos) check_symbol_exists(SQLExecute "sql.h" HAVE_ODBC_DEV)
if(NOT (HAVE_ODBC_DEV))
unset(HAVE_ODBC_DEV CACHE)
message(WARNING "unixodbc-dev is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc-dev")
else ()
message(STATUS "unixodbc/unixodbc-dev are installed, and odbc connector will be built")
AUX_SOURCE_DIRECTORY(src SRC)
install(CODE "execute_process(COMMAND sudo odbcinst -i -d -f ${CMAKE_CURRENT_SOURCE_DIR}/src/template.ini # generate dynamic library (*.so)
COMMAND odbcinst -i -s -f ${CMAKE_CURRENT_SOURCE_DIR}/src/template.dsn ADD_LIBRARY(todbc SHARED ${SRC})
COMMAND echo odbc install done)") SET_TARGET_PROPERTIES(todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1)
TARGET_LINK_LIBRARIES(todbc taos)
ADD_SUBDIRECTORY(tests) install(CODE "execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/src/install.sh ${CMAKE_BINARY_DIR})")
ADD_SUBDIRECTORY(tests)
endif()
ELSE ()
message(WARNING "unixodbc is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc-dev")
ENDIF ()
ENDIF ()
#!/bin/bash
set -u
BLD_DIR="$1"
rm -f "${BLD_DIR}/template.ini"
rm -f "${BLD_DIR}/template.dsn"
cat > "${BLD_DIR}/template.ini" <<EOF
[TAOS]
Description = taos odbc driver
Driver = ${BLD_DIR}/build/lib/libtodbc.so
EOF
cat > "${BLD_DIR}/template.dsn" <<EOF
[TAOS_DSN]
Description=Connection to TAOS
Driver=TAOS
EOF
sudo odbcinst -i -d -f "${BLD_DIR}/template.ini" &&
odbcinst -i -s -f "${BLD_DIR}/template.dsn" &&
echo "odbc install done"
[TAOS_DSN]
Description=Connection to TAOS
Driver=TAOS
Server=localhost:1234
[TAOS]
Description = taos odbc driver
Driver = /home/xxh/Documents/TDengine/debug/build/lib/libtodbc.so
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册