
#rights reserved
cmake_minimum_required(VERSION 3.10)

#project name
set(PROJECT_NAME "DTU")

message(INFO " SYSTEM_ARCH:${SYSTEM_ARCH}\n")
set(CMAKE_BUILD_TYPE RELEASE)
set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++0x")

macro(get_git_branch _git_branch)
    find_package(Git QUIET)
    if(GIT_FOUND)
      execute_process(
        COMMAND ${GIT_EXECUTABLE} symbolic-ref -q HEAD
        OUTPUT_VARIABLE ${_git_branch}
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_QUIET
        WORKING_DIRECTORY
          ${CMAKE_CURRENT_SOURCE_DIR}
        )
    endif()
endmacro()

# 获取当前的分支
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}\")

include(${ROOT_DIR}/buildtools/cmake/gcc-arm-none-eabi-9-2020-q2-update.cmake)
project(${PROJECT_NAME} C ASM)

set(PROJECT_SOURCE_DIR ${ROOT_DIR}/)
set(PROJECT_BINARY_DIR ${ROOT_DIR}/out/${PRODUCT_NAME}/)
set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(CMAKE_BINARY_DIR ${PROJECT_BINARY_DIR})
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install)
message(STATUS "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}, PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}")

add_subdirectory(${PROJECT_SOURCE_DIR}/Lora/DTU ${PROJECT_BINARY_DIR}/Lora/DTU)