set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) # option(MYDEBUG "enable debug compilation" OFF) # if (MYDEBUG) # add_definitions(-DMYDEBUG) # message(STATUS "Currently is in debug mode") # else() # message(STATUS "Currently is not in debug mode") # endif()
set(FREERTOS_CONFIG_FILE_DIRECTORY ${PROJECT_SOURCE_DIR}/include CACHE STRING "Absolute path to the directory with FreeRTOSConfig.h") add_subdirectory(os/freertos)
# # on the basic of debug to set CFLAGS # if (debug STREQUAL "yes") # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O0 -ggdb3") # else() # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2") # endif()
# # on the basic of r5_LITTLE_FLASH to set CFLAGS # if (r5_LITTLE_FLASH STREQUAL "TRUE") # # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSAMPLE_620U_NAND") # endif()
# User is responsible to set two mandatory options: # FREERTOS_CONFIG_FILE_DIRECTORY # FREERTOS_PORT # # User can choose which heap implementation to use (either the implementations # included with FreeRTOS [1..5] or a custom implementation ) by providing the # option FREERTOS_HEAP. If the option is not set, the cmake will default to # using heap_4.c.
# Absolute path to FreeRTOS config file directory # set(FREERTOS_CONFIG_FILE_DIRECTORY ${FREERTOS_CONFIG_FILE_PATH} CACHE STRING "Absolute path to the directory with FreeRTOSConfig.h")
if(NOT FREERTOS_CONFIG_FILE_DIRECTORY) message(FATAL_ERROR " FreeRTOSConfig.h file directory not specified. Please specify absolute path to it from top-level CMake file:\n" " set(FREERTOS_CONFIG_FILE_DIRECTORY <absolute path to FreeRTOSConfig.h directory> CACHE STRING \"\")\n" " or from CMake command line option:\n" " -DFREERTOS_CONFIG_FILE_DIRECTORY='/absolute_path/to/FreeRTOSConfig.h/directory'") elseif(NOT EXISTS ${FREERTOS_CONFIG_FILE_DIRECTORY}/FreeRTOSConfig.h) message(FATAL_ERROR " FreeRTOSConfig.h file not found in the directory specified (${FREERTOS_CONFIG_FILE_DIRECTORY})\n" " Please specify absolute path to it from top-level CMake file:\n" " set(FREERTOS_CONFIG_FILE_DIRECTORY <absolute path to FreeRTOSConfig.h directory> CACHE STRING \"\")\n" " or from CMake command line option:\n" " -DFREERTOS_CONFIG_FILE_DIRECTORY='/absolute_path/to/FreeRTOSConfig.h/directory'") endif()
# Heap number or absolute path to custom heap implementation provided by user set(FREERTOS_HEAP "4" CACHE STRING "FreeRTOS heap model number. 1 .. 5. Or absolute path to custom heap source file")
# FreeRTOS port option set(FREERTOS_PORT "GCC_ARM_COTEXT_R5" CACHE STRING "FreeRTOS port name")
if(NOT FREERTOS_PORT) message(FATAL_ERROR " FREERTOS_PORT is not set. Please specify it from top-level CMake file (example):\n" " set(FREERTOS_PORT GCC_ARM_CM4F CACHE STRING \"\")\n" " or from CMake command line option:\n" " -DFREERTOS_PORT=GCC_ARM_CM4F\n" " \n" " Available port options:\n" " GCC_ARM_COTEXT_R5 - Compiller: GCC Target: ARM Cortex-R5") endif()
# If FREERTOS_HEAP is digit between 1 .. 5 - it is heap number, otherwise - it is path to custom heap source file $<IF:$<BOOL:$<FILTER:${FREERTOS_HEAP},EXCLUDE,^[1-5]$>>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c> )
target_include_directories(freertos_kernel PUBLIC include portable/GCC/ARM_COTEXT_R5 ${FREERTOS_CONFIG_FILE_DIRECTORY} )
# FreeRTOS internal cmake file. Do not use it in user top-level project
add_library(freertos_kernel_port STATIC # ARM-Cortext-R5 port for GCC $<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_COTEXT_R5>: portable_port.c portASM.S>
# 16-Bit DOS ports for BCC $<$<STREQUAL:${FREERTOS_PORT},BCC_16BIT_DOS_FLSH186>: BCC/16BitDOS/common/portcomn.c BCC/16BitDOS/Flsh186/port.c> )
if( FREERTOS_PORT MATCHES "GCC_ARM_CM(3|4)_MPU" OR FREERTOS_PORT STREQUAL "IAR_ARM_CM4F_MPU" OR FREERTOS_PORT STREQUAL "RVDS_ARM_CM4_MPU" OR FREERTOS_PORT MATCHES "GCC_ARM_CM(23|33|55|85)_NTZ_NONSECURE" OR FREERTOS_PORT MATCHES "GCC_ARM_CM(23|33|55|85)_NONSECURE" OR FREERTOS_PORT MATCHES "GCC_ARM_CM(33|55|85)_TFM" OR FREERTOS_PORT MATCHES "IAR_ARM_CM(23|33|55|85)_NTZ_NONSECURE" OR FREERTOS_PORT MATCHES "IAR_ARM_CM(23|33|55|85)_NONSECURE" ) target_sources(freertos_kernel_port PRIVATE Common/mpu_wrappers.c) endif()
target_include_directories(freertos_kernel_port PUBLIC # ARM-Cortext-R5 port for GCC $<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_COTEXT_R5>:${CMAKE_CURRENT_LIST_DIR}>
# 16-Bit DOS ports for BCC $<$<STREQUAL:${FREERTOS_PORT},BCC_16BIT_DOS_FLSH186>: ${CMAKE_CURRENT_LIST_DIR}/BCC/16BitDOS/common ${CMAKE_CURRENT_LIST_DIR}/BCC/16BitDOS/Flsh186>
target_link_libraries(freertos_kernel_port PUBLIC $<$<STREQUAL:${FREERTOS_PORT},GCC_RP2040>:pico_base_headers> $<$<STREQUAL:${FREERTOS_PORT},GCC_XTENSA_ESP32>:idf::esp32> PRIVATE freertos_kernel "$<$<STREQUAL:${FREERTOS_PORT},GCC_RP2040>:hardware_clocks;hardware_exception>" $<$<STREQUAL:${FREERTOS_PORT},MSVC_MINGW>:winmm> # Windows library which implements timers )
message( [STATUS|WARNING|AUTHOR_WARNING|SEND_ERROR|FATAL_ERROR] "Message to display" ...)
STATUS
状态消息,自动在消息前增加--以示区别
1 2 3
message(STATUS "Detecting system: Linux")
[cmake] -- Detecting system: Linux
WARFATAL_ERRORNING
告警消息,消息单独显示一行,CMake会继续执行
1 2 3 4 5 6 7
message(WARNING "Detecting system: Linux")
[cmake] CMake Warning at CMakeLists.txt:8 (message): [cmake] Detecting system: Linux [cmake] [cmake] [cmake] Not searching for unused variables given on the command line.
AUTHOR_WARNING
开发者告警消息,消息单独显示一行,CMake会继续执行
1 2 3 4 5 6 7
message(AUTHOR_WARNING "Detecting system: Linux")
[cmake] CMake Warning (dev) at CMakeLists.txt:8 (message): [cmake] Detecting system: Linux [cmake] This warning is for project developers. Use -Wno-dev to suppress it. [cmake] [cmake] Not searching for unused variables given on the command line.
SEND_ERROR
错误消息,消息单独显示一行,CMake会继续执行但会跳过生成步骤
1 2 3 4 5 6 7 8 9
message(SEND_ERROR "Detecting system: Linux")
[cmake] CMake Error at CMakeLists.txt:8 (message): [cmake] Detecting system: Linux [cmake] [cmake] [cmake] Not searching for unused variables given on the command line. [cmake] -- Configuring incomplete, errors occurred! [cmake] See also "/root/workspace/tcl3/build/CMakeFiles/CMakeOutput.log".
FATAL_ERROR
错误消息,消息单独显示一行,CMake会终止所有处理
1 2 3 4 5 6 7 8 9
message(FATAL_ERROR "Detecting system: Linux")
[cmake] CMake Error at CMakeLists.txt:8 (message): [cmake] Detecting system: Linux [cmake] [cmake] [cmake] Not searching for unused variables given on the command line. [cmake] -- Configuring incomplete, errors occurred! [cmake] See also "/root/workspace/tcl3/build/CMakeFiles/CMakeOutput.log".