CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) IF (TD_LINUX) AUX_SOURCE_DIRECTORY(src SRC) INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/src/inc ${TD_OS_DIR}/inc) ADD_LIBRARY(tutil ${SRC}) TARGET_LINK_LIBRARIES(tutil pthread os m rt) FIND_PATH(ICONV_INCLUDE_EXIST iconv.h /usr/include/ /usr/local/include/) IF (ICONV_INCLUDE_EXIST) ADD_DEFINITIONS(-DUSE_LIBICONV) FIND_PATH(ICONV_LIBRARY_A_EXIST libiconv.a /usr/lib/ /usr/local/lib/ /lib64) FIND_PATH(ICONV_LIBRARY_SO_EXIST libiconv.so /usr/lib/ /usr/local/lib/ /lib64) IF (ICONV_LIBRARY_A_EXIST OR ICONV_LIBRARY_SO_EXIST) MESSAGE(STATUS "Use the installed libiconv library") TARGET_LINK_LIBRARIES(tutil iconv) ELSE () # libiconv library is already included in GLIBC, MESSAGE(STATUS "Use the iconv functions in GLIBC") ENDIF () ELSE () MESSAGE(STATUS "Failed to find iconv, use default encoding method") ENDIF () ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") ADD_DEFINITIONS(-DUSE_LIBICONV) INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/pthread) INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/iconv) INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/regex) INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/src/inc) INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc) LIST(APPEND SRC ./src/ihash.c) LIST(APPEND SRC ./src/lz4.c) LIST(APPEND SRC ./src/shash.c) LIST(APPEND SRC ./src/sql.c) LIST(APPEND SRC ./src/tbase64.c) LIST(APPEND SRC ./src/tcompression.c) LIST(APPEND SRC ./src/tcache.c) LIST(APPEND SRC ./src/textbuffer.c) LIST(APPEND SRC ./src/tglobalcfg.c) LIST(APPEND SRC ./src/thash.c) LIST(APPEND SRC ./src/thashutil.c) LIST(APPEND SRC ./src/thistogram.c) LIST(APPEND SRC ./src/tidpool.c) LIST(APPEND SRC ./src/tinterpolation.c) LIST(APPEND SRC ./src/tlog.c) LIST(APPEND SRC ./src/tlosertree.c) LIST(APPEND SRC ./src/tmd5.c) LIST(APPEND SRC ./src/tmempool.c) LIST(APPEND SRC ./src/tmodule.c) LIST(APPEND SRC ./src/tsched.c) LIST(APPEND SRC ./src/tskiplist.c) LIST(APPEND SRC ./src/tsocket.c) LIST(APPEND SRC ./src/tstatus.c) LIST(APPEND SRC ./src/tstoken.c) LIST(APPEND SRC ./src/ttime.c) LIST(APPEND SRC ./src/ttimer.c) LIST(APPEND SRC ./src/ttokenizer.c) LIST(APPEND SRC ./src/ttypes.c) LIST(APPEND SRC ./src/tutil.c) LIST(APPEND SRC ./src/version.c) ADD_LIBRARY(tutil ${SRC}) TARGET_LINK_LIBRARIES(tutil iconv regex pthread os winmm IPHLPAPI ws2_32) ELSEIF (TD_DARWIN) ADD_DEFINITIONS(-DUSE_LIBICONV) INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/src/inc) INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc) LIST(APPEND SRC ./src/ihash.c) LIST(APPEND SRC ./src/shash.c) LIST(APPEND SRC ./src/sql.c) LIST(APPEND SRC ./src/tbase64.c) LIST(APPEND SRC ./src/tcache.c) LIST(APPEND SRC ./src/textbuffer.c) LIST(APPEND SRC ./src/tglobalcfg.c) LIST(APPEND SRC ./src/thash.c) LIST(APPEND SRC ./src/thashutil.c) LIST(APPEND SRC ./src/thistogram.c) LIST(APPEND SRC ./src/tidpool.c) LIST(APPEND SRC ./src/tinterpolation.c) LIST(APPEND SRC ./src/tlog.c) LIST(APPEND SRC ./src/tlosertree.c) LIST(APPEND SRC ./src/tmd5.c) LIST(APPEND SRC ./src/tmempool.c) LIST(APPEND SRC ./src/tmodule.c) LIST(APPEND SRC ./src/tsched.c) LIST(APPEND SRC ./src/tskiplist.c) LIST(APPEND SRC ./src/tsocket.c) LIST(APPEND SRC ./src/tstatus.c) LIST(APPEND SRC ./src/tstoken.c) LIST(APPEND SRC ./src/ttime.c) LIST(APPEND SRC ./src/ttimer.c) LIST(APPEND SRC ./src/ttokenizer.c) LIST(APPEND SRC ./src/ttypes.c) LIST(APPEND SRC ./src/tutil.c) LIST(APPEND SRC ./src/version.c) ADD_LIBRARY(tutil ${SRC}) TARGET_LINK_LIBRARIES(tutil iconv pthread os) ENDIF ()