CMakeLists.txt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #
  2. # Copyright (c) 2022-2023 Project CHIP Authors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. cmake_minimum_required(VERSION 3.21)
  17. get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
  18. get_filename_component(OPEN_IOT_SDK_CONFIG ${CHIP_ROOT}/config/openiotsdk REALPATH)
  19. get_filename_component(OPEN_IOT_SDK_EXAMPLE_COMMON ${CHIP_ROOT}/examples/platform/openiotsdk REALPATH)
  20. get_filename_component(SHELL_COMMON ${CHIP_ROOT}/examples/shell/shell_common REALPATH)
  21. list(APPEND CMAKE_MODULE_PATH ${OPEN_IOT_SDK_CONFIG}/cmake)
  22. set(APP_TARGET chip-openiotsdk-shell-example_ns)
  23. # Toolchain files need to exist before first call to project
  24. include(toolchain)
  25. project(${APP_TARGET} LANGUAGES C CXX ASM)
  26. include(sdk)
  27. add_executable(${APP_TARGET})
  28. # Application CHIP build configuration
  29. set(CONFIG_CHIP_LIB_SHELL YES)
  30. include(chip)
  31. add_subdirectory(${OPEN_IOT_SDK_EXAMPLE_COMMON}/app ./app_build)
  32. target_compile_definitions(openiotsdk-startup
  33. PRIVATE
  34. IOT_SDK_APP_SERIAL_BAUDRATE=9600
  35. )
  36. target_compile_definitions(openiotsdk-startup
  37. PRIVATE
  38. IOT_SDK_APP_MAIN_STACK_SIZE=8192
  39. )
  40. target_include_directories(${APP_TARGET}
  41. PRIVATE
  42. main/include
  43. ${SHELL_COMMON}/include
  44. )
  45. target_sources(${APP_TARGET}
  46. PRIVATE
  47. main/main_ns.cpp
  48. ${SHELL_COMMON}/cmd_misc.cpp
  49. ${SHELL_COMMON}/globals.cpp
  50. )
  51. target_link_libraries(${APP_TARGET}
  52. openiotsdk-startup
  53. openiotsdk-app
  54. )
  55. include(linker)
  56. set_target_link(${APP_TARGET})
  57. sdk_post_build(${APP_TARGET})