CMakeLists.txt 2.2 KB

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