
#rights reserved
cmake_minimum_required(VERSION 3.6)

# set(CMAKE_TOOLCHAIN_FILE ${ROOT_DIR}/buildtools/cmake/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.cmake)
include(${ROOT_DIR}/buildtools/cmake/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.cmake)
#project name
set(PROJECT_NAME "leo-das")

message(INFO " SYSTEM_ARCH:${SYSTEM_ARCH}\n")
set(CMAKE_BUILD_TYPE RELEASE)
set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++11 -Wno-error=implicit-function-declaration -Wno-error=int-conversion")
set(CMAKE_C_FLAGS "-O3 -fPIC -Wunused-result -Wno-error=implicit-function-declaration -Wno-error=int-conversion")

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

add_definitions(-DDAS_VERSION=\"${_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(-DUSE_HTNICE)
add_definitions(-DHTNICE_K4)
# add_definitions(-DLINUX)

set(BUILD_SHARED_LIBS OFF)
set(EVENT_LIBRARY_TYPE STATIC)

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

# set(OPENSSL_ROOT_DIR "${PRODUCT_BUILD_DIR}/thirdparty/openssl")
# set(OPENSSL_CRYPTO_LIBRARY ${PRODUCT_BUILD_DIR}/thirdparty/openssl/crypto/libcrypto.so)
# set(OPENSSL_SSL_LIBRARY ${PRODUCT_BUILD_DIR}/thirdparty/openssl/ssl/libssl.so)
# set(OPENSSL_INCLUDE_DIR "${PRODUCT_BUILD_DIR}/thirdparty/openssl/include")
# # set(CMAKE_EXE_LINKER_FLAGS "-L${PRODUCT_BUILD_DIR}/thirdparty/openssl/crypto -lcrypto -L${PRODUCT_BUILD_DIR}/thirdparty/openssl/ssl -lssl")
# # INCLUDE thirdparty/openssl/include    LINK thirdparty/openssl/ssl thirdparty/openssl/crypto
# build_project(thirdparty/openssl)
# build_subdirectory(thirdparty/mbedtls)
# build_subdirectory(thirdparty/zlib)

set(LIBXML2_WITH_PYTHON OFF)
# build_subdirectory(thirdparty/libxml2 INCLUDE thirdparty/libxml2)

build_subdirectory(thirdparty/SQLiteCpp INCLUDE thirdparty/SQLiteCpp/sqlite3)

build_subdirectory(utils)

# build_subdirectory(foundation/gw_leo)

# build_subdirectory(foundation/webconfig)

# build_subdirectory(Lora/sx1302_hal)

# {
#     "name": "xfrpc",
#     "options":["-DTHIRDPARTY_STATIC_BUILD=arm"],
#     "include":["$PRODUCT_ROOT_DIR/thirdparty/zlib", "$PRODUCT_BUILD_DIR/thirdparty/zlib"],
#     "deps":["zlib"]
# },
# {
#     "name": "libevent",
#     "options":["-DEVENT__DISABLE_TESTS=ON", "-DEVENT__HAVE_EPOLL_PWAIT2=0"]
# }