1cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) 2 3# Set up the project 4project(levelx 5 LANGUAGES C ASM 6) 7 8option(LX_STANDALONE_ENABLE "Enable LevelX in standalone mode" OFF) 9option(LX_ENABLE_FILE_SERVERS "Includes a dependency on FileX" ON) 10 11if(NOT DEFINED THREADX_ARCH) 12 message(FATAL_ERROR "Error: THREADX_ARCH not defined") 13endif() 14if(NOT DEFINED THREADX_TOOLCHAIN) 15 message(FATAL_ERROR "Error: THREADX_TOOLCHAIN not defined") 16endif() 17 18 19# Define our target library and an alias for consumers 20add_library(${PROJECT_NAME}) 21add_library("azrtos::${PROJECT_NAME}" ALIAS ${PROJECT_NAME}) 22 23# Define any required dependencies between this library and others 24if(NOT LX_STANDALONE_ENABLE) 25 target_link_libraries(${PROJECT_NAME} PUBLIC 26 "azrtos::threadx") 27endif() 28 29if(LX_ENABLE_FILE_SERVERS) 30 message(STATUS "LX_ENABLE_FILE_SERVERS - defined") 31 target_link_libraries(${PROJECT_NAME} PUBLIC "azrtos::filex") 32endif() 33 34# A place for generated/copied include files (no need to change) 35set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc) 36 37# Pick up the common stuff 38add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common) 39 40# Include the user's override file if required 41if (NOT LX_USER_FILE) 42 message(STATUS "Using default lx_user.h file") 43 set(LX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common/inc/lx_user_sample.h) 44else() 45 message(STATUS "Using custom lx_user.h file from ${LX_USER_FILE}") 46endif() 47configure_file(${LX_USER_FILE} ${CUSTOM_INC_DIR}/lx_user.h COPYONLY) 48target_include_directories(${PROJECT_NAME} 49 PUBLIC 50 ${CUSTOM_INC_DIR} 51) 52 53if(NOT LX_STANDALONE_ENABLE) 54 target_compile_definitions(${PROJECT_NAME} PUBLIC "LX_INCLUDE_USER_DEFINE_FILE" ) 55else() 56 # Enable LevelX and FileX standalone support (No Azure RTOS support) 57 set(FX_STANDALONE_ENABLE ON CACHE BOOL "Standalone enable") 58 target_compile_definitions(${PROJECT_NAME} PUBLIC "LX_INCLUDE_USER_DEFINE_FILE" -DLX_STANDALONE_ENABLE -DFX_STANDALONE_ENABLE) 59endif() 60 61# Enable a build target that produces a ZIP file of all sources 62set(CPACK_SOURCE_GENERATOR "ZIP") 63set(CPACK_SOURCE_IGNORE_FILES 64 \\.git/ 65 \\.github/ 66 _build/ 67 \\.git 68 \\.gitattributes 69 \\.gitignore 70 ".*~$" 71) 72set(CPACK_VERBATIM_VARIABLES YES) 73include(CPack) 74 75