1cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) 2 3# Set up the project 4project(threadx 5 LANGUAGES C ASM 6) 7 8if(NOT DEFINED THREADX_ARCH) 9 message(FATAL_ERROR "Error: THREADX_ARCH not defined") 10endif() 11if(NOT DEFINED THREADX_TOOLCHAIN) 12 message(FATAL_ERROR "Error: THREADX_TOOLCHAIN not defined") 13endif() 14message(STATUS "THREADX_ARCH: ${THREADX_ARCH}") 15message(STATUS "THREADX_TOOLCHAIN: ${THREADX_TOOLCHAIN}") 16 17# Define our target library and an alias for consumers 18add_library(${PROJECT_NAME}) 19add_library("azrtos::${PROJECT_NAME}" ALIAS ${PROJECT_NAME}) 20 21# A place for generated/copied include files (no need to change) 22set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc) 23 24# Pick up the port specific variables and apply them 25if(DEFINED THREADX_CUSTOM_PORT) 26 add_subdirectory(${THREADX_CUSTOM_PORT} threadx_port) 27else() 28 add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN}) 29endif() 30 31# Pick up the common stuff 32add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common) 33 34# Define the FreeRTOS adaptation layer 35add_library(freertos-threadx EXCLUDE_FROM_ALL) 36target_include_directories(freertos-threadx 37 PUBLIC 38 ${CMAKE_CURRENT_LIST_DIR}/utility/rtos_compatibility_layers/FreeRTOS 39) 40target_sources(freertos-threadx 41 PRIVATE 42 ${CMAKE_CURRENT_LIST_DIR}/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c 43) 44target_link_libraries(freertos-threadx PUBLIC threadx) 45 46# If the user provided an override, copy it to the custom directory 47if (NOT TX_USER_FILE) 48 message(STATUS "Using default tx_user.h file") 49 set(TX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common/inc/tx_user_sample.h) 50else() 51 message(STATUS "Using custom tx_user.h file from ${TX_USER_FILE}") 52endif() 53configure_file(${TX_USER_FILE} ${CUSTOM_INC_DIR}/tx_user.h COPYONLY) 54target_include_directories(${PROJECT_NAME} 55 PUBLIC 56 ${CUSTOM_INC_DIR} 57) 58target_compile_definitions(${PROJECT_NAME} PUBLIC "TX_INCLUDE_USER_DEFINE_FILE" ) 59 60# Enable a build target that produces a ZIP file of all sources 61set(CPACK_SOURCE_GENERATOR "ZIP") 62set(CPACK_SOURCE_IGNORE_FILES 63 \\.git/ 64 \\.github/ 65 _build/ 66 \\.git 67 \\.gitattributes 68 \\.gitignore 69 ".*~$" 70) 71set(CPACK_VERBATIM_VARIABLES YES) 72include(CPack)