cmake_minimum_required(VERSION 3.20) if (NOT DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() if (NOT DEFINED TARGET) set(TARGET open429i) endif() # Prevent in-source builds # If an in-source build is attempted, you will still need to clean up a few # files manually. set(CMAKE_DISABLE_SOURCE_CHANGES ON) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not " "allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a " "separate build directory and run cmake from there.") endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if (DEFINED APP_CHIP_BASE) set(tgt_chip_base ${APP_CHIP_BASE}) else() set(tgt_chip_base 0x0800c000) endif() if (NOT DEFINED HXTAL_VALUE) set(HXTAL_VALUE 8000000) endif() if (NOT DEFINED CHIP_TYPE) set(CHIP_TYPE GD32F407) endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake") if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/arm_gcc.cmake) endif() set(gd32f4xx_root ${CMAKE_CURRENT_LIST_DIR}/Firmware) include(gd32f4xx_periph) # set(stm32f4xx_hal_root ${CMAKE_CURRENT_LIST_DIR}/Libraries) # include(stm32f4xx_hal) set(rtthread_root ${CMAKE_CURRENT_LIST_DIR}/rt-thread) include(rt_thread) project(gd32f4xx VERSION 1.0 LANGUAGES C CXX ASM ) # Find the git revision if this is a working copy. if(EXISTS ${PROJECT_SOURCE_DIR}/.git) find_package(Git) if(Git_FOUND) execute_process( COMMAND "${GIT_EXECUTABLE}" describe --always HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE res OUTPUT_VARIABLE GIT_COMMIT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Project current git hash: ${GIT_COMMIT}") else() message(WARNING "Git not found. Can not determine current commit hash.") set(GIT_COMMIT ${PROJECT_VERSION}) endif() else() set(GIT_COMMIT ${PROJECT_VERSION}) endif() add_subdirectory(targets/boot) #add_subdirectory(targets/${TARGET}) set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) set(CPACK_PACKAGE_VERSION ${GIT_COMMIT}) set(CPACK_PACKAGE_CONTACT "surenyi82@163.com") set(CPACK_PACKAGE_DESCRIPTION "gd32f4xx with rt-thread support") set(CPACK_SOURCE_GENERATOR "TXZ;ZIP") set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-${GIT_COMMIT}) set(CPACK_SOURCE_IGNORE_FILES build/ \\.git/ \\.clangd \\.clang-format \\.gitattributes README.md) set(CPACK_VERBATIM_VARIABLES YES) include(CPack)