1cmake_minimum_required(VERSION 3.13 FATAL_ERROR) 2cmake_policy(SET CMP0054 NEW) 3cmake_policy(SET CMP0057 NEW) 4 5project(threadx_test LANGUAGES C) 6 7# Set build configurations 8set(BUILD_CONFIGURATIONS 9 default_build_coverage no_cache_build no_cache_standalone_build 10 fault_tolerant_build_coverage no_check_build no_cache_fault_tolerant_build 11 standalone_build_coverage standalone_fault_tolerant_build_coverage 12 standalone_no_cache_fault_tolerant_build) 13set(CMAKE_CONFIGURATION_TYPES 14 ${BUILD_CONFIGURATIONS} 15 CACHE STRING "list of supported configuration types" FORCE) 16set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 17 ${CMAKE_CONFIGURATION_TYPES}) 18list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE) 19if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST 20 CMAKE_CONFIGURATION_TYPES))) 21 set(CMAKE_BUILD_TYPE 22 "${BUILD_TYPE}" 23 CACHE STRING "Build Type of the project" FORCE) 24endif() 25 26message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 27message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") 28set(FX_FAULT_TOLERANT_DEFINITIONS 29 -DFX_ENABLE_FAULT_TOLERANT -DFX_UPDATE_FILE_SIZE_ON_ALLOCATE 30 -DFX_FAULT_TOLERANT_TRANSACTION_FAIL_FUNCTION) 31set(default_build_coverage "") 32set(no_cache_build -DFX_DISABLE_CACHE -DFX_DISABLE_FAT_ENTRY_REFRESH) 33set(fault_tolerant_build_coverage ${FX_FAULT_TOLERANT_DEFINITIONS}) 34set(standalone_build_coverage -DFX_STANDALONE_ENABLE) 35set(standalone_fault_tolerant_build_coverage ${FX_FAULT_TOLERANT_DEFINITIONS} 36 -DFX_STANDALONE_ENABLE) 37set(no_cache_standalone_build -DFX_DISABLE_CACHE -DFX_STANDALONE_ENABLE) 38set(no_check_build ${FX_COMPILE_DEFINITIONS} -DFX_DISABLE_ERROR_CHECKING) 39set(no_cache_fault_tolerant_build ${no_cache_build} ${FX_FAULT_TOLERANT_DEFINITIONS}) 40set(standalone_no_cache_fault_tolerant_build ${no_cache_build} ${FX_FAULT_TOLERANT_DEFINITIONS} -DFX_STANDALONE_ENABLE) 41 42add_compile_options( 43 -m32 44 -std=c99 45 -ggdb 46 -g3 47 -gdwarf-2 48 -fdiagnostics-color 49 -Werror 50 -DFX_REGRESSION_TEST 51 ${${CMAKE_BUILD_TYPE}}) 52add_link_options(-m32) 53 54if(CMAKE_BUILD_TYPE MATCHES ".*standalone.*") 55 set(FX_STANDALONE_ENABLE 56 ON 57 CACHE BOOL "Enable Filex in standalone mode") 58endif() 59 60enable_testing() 61 62add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../.. filex) 63add_subdirectory(regression) 64add_subdirectory(samples) 65 66# Coverage 67if(CMAKE_BUILD_TYPE MATCHES ".*_coverage") 68 target_compile_options(filex PRIVATE -fprofile-arcs -ftest-coverage) 69 target_link_options(filex PRIVATE -fprofile-arcs -ftest-coverage) 70endif() 71 72# Build ThreadX library once 73if(NOT FX_STANDALONE_ENABLE) 74 execute_process(COMMAND ${CMAKE_CURRENT_LIST_DIR}/run.sh build_libs) 75 add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_LIST_DIR}/run.sh 76 build_libs) 77 add_dependencies(filex build_libs) 78 target_include_directories(filex PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc) 79 add_library(threadx SHARED IMPORTED GLOBAL) 80 add_library("azrtos::threadx" ALIAS threadx) 81 set_target_properties( 82 threadx PROPERTIES IMPORTED_LOCATION 83 ${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so) 84endif() 85 86target_compile_options( 87 filex 88 PRIVATE -Werror 89 -Wall 90 -Wextra 91 -pedantic 92 -fmessage-length=0 93 -fsigned-char 94 -ffunction-sections 95 -fdata-sections 96 -Wunused 97 -Wuninitialized 98 -Wmissing-declarations 99 -Wconversion 100 -Wpointer-arith 101 -Wshadow 102 -Wlogical-op 103 -Waggregate-return 104 -Wfloat-equal) 105 106