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