
#rights reserved
cmake_minimum_required(VERSION 3.22)

include("${ROOT_DIR}/buildtools/cmake/toolchain_common.cmake")
#project name
set(PROJECT_NAME "iot-tools")

message(INFO " SYSTEM_ARCH:${SYSTEM_ARCH}\n")

# 获取当前的分支
set(GIT_BRANCH "")
get_git_branch(GIT_BRANCH)
string(REGEX REPLACE ".*/(.*)" "\\1" _git_branch "${GIT_BRANCH}")
message(STATUS "Git branch is ${_git_branch}")                     # 宏的结束

project(${PROJECT_NAME})

message("PRODUCT_NAME: ${PRODUCT_NAME}")
message(STATUS "PROJECT_SOURCE_DIR: ${PRODUCT_ROOT_DIR}, PROJECT_BINARY_DIR: ${PRODUCT_BUILD_DIR}")
add_definitions(-DDAS_VERSION=\"${PRODUCT_VERSION}\")
add_definitions(-DPRODUCT_NAME=\"${PRODUCT_NAME}\")
add_definitions(-DPRODUCT_${PRODUCT_NAME})

set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs?" FORCE)

include_directories(${PRODUCT_ROOT_DIR})
include_directories(${PRODUCT_ROOT_DIR}/thirdparty)
include_directories(${PRODUCT_ROOT_DIR}/vendor/${PRODUCT_NAME})
include_directories(${PRODUCT_BUILD_DIR}/thirdparty)

find_library(OPENSSL_SSL_LIBRARY ssl ${OPENSSL_ROOT_DIR}/lib64 NO_DEFAULT_PATH)
find_library(OPENSSL_CRYPTO_LIBRARY crypto ${OPENSSL_ROOT_DIR}/lib64 NO_DEFAULT_PATH)
message("OPENSSL: ${OPENSSL_ROOT_DIR}/ssl, OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}, OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}, OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")

set(LIBXML2_WITH_PYTHON OFF)

include_directories(${PRODUCT_ROOT_DIR}/thirdparty/SQLiteCpp/sqlite3)

include_directories(./ ${PRODUCT_ROOT_DIR}/foundation/
        ${LIBUV_INCLUDE_DIR})
# OBJECT EXCLUDE_FROM_ALL
add_library(vendor STATIC ${PRODUCT_ROOT_DIR}/vendor/vendor_base.cpp)
target_include_directories(vendor PUBLIC ${PRODUCT_ROOT_DIR}/vendor)
target_link_directories(vendor PUBLIC ${LIBUV_LIBS_DIR})
target_link_libraries(vendor uv)
build_subdirectory(utils)
# build_subdirectory(foundation/hmi)
build_subdirectory(Lora/chirpstack-handler)
