CMakeLists.txt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # CMake 最低版本号要求
  2. cmake_minimum_required (VERSION 3.5)
  3. set(CMAKE_BUILD_TYPE "Debug")
  4. set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
  5. set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wall")
  6. set(CMAKE_EXE_LINKER_FLAGS "-Wl,-Map=luatos.map")
  7. set(TOPROOT "../..")
  8. # 项目信息
  9. project (luatos)
  10. # 一定一定要先添加本地的头文件
  11. include_directories(./include)
  12. include_directories(${TOPROOT}/lua/include
  13. ${TOPROOT}/luat/include
  14. ${TOPROOT}/components/freertos/include
  15. )
  16. IF (WIN32)
  17. include_directories(${TOPROOT}/components/freertos/portable/MSVC-MingW)
  18. aux_source_directory(${TOPROOT}/components/freertos/portable/MSVC-MingW MM_SRCS)
  19. ELSE ()
  20. include_directories(${TOPROOT}/components/freertos/portable/ThirdParty/GCC/Posix)
  21. include_directories(${TOPROOT}/components/freertos/portable/ThirdParty/GCC/Posix/utils)
  22. aux_source_directory(${TOPROOT}/components/freertos/portable/ThirdParty/GCC/Posix MM_SRCS)
  23. aux_source_directory(${TOPROOT}/components/freertos/portable/ThirdParty/GCC/Posix/utils
  24. MM2_SRCS)
  25. ENDIF ()
  26. include_directories(${TOPROOT}/luat/packages/lfs)
  27. # include_directories(${TOPROOT}/components/lcd)
  28. aux_source_directory(./port PORT_SRCS)
  29. aux_source_directory(${TOPROOT}/lua/src LUA_SRCS)
  30. #aux_source_directory(${TOPROOT}/luat/freertos FTOS_T_SRCS)
  31. aux_source_directory(${TOPROOT}/components/freertos RTOS_SRCS)
  32. aux_source_directory(${TOPROOT}/components/freertos/port RTOS_PORT_SRCS)
  33. aux_source_directory(${TOPROOT}/luat/packages/lua-cjson CJSON_SRCS)
  34. # aux_source_directory(${TOPROOT}/components/lcd LCD_SRCS)
  35. add_library(freertos10 ${PORT_SRCS} ${RTOS_SRCS} ${RTOS_PORT_SRCS} ${MM_SRCS} ${MM2_SRCS})
  36. add_library(lua ${LUA_SRCS})
  37. add_library(luatos_msys ${PORT_SRCS})
  38. add_library(cjson ${CJSON_SRCS})
  39. add_library(luat ${TOPROOT}/luat/modules/luat_main.c
  40. ${TOPROOT}/luat/modules/luat_ota.c
  41. ${TOPROOT}/luat/modules/luat_luat_bin.c
  42. ${TOPROOT}/luat/modules/luat_lib_rtos.c
  43. ${TOPROOT}/luat/modules/luat_lib_timer.c
  44. ${TOPROOT}/luat/modules/luat_lib_log.c
  45. ${TOPROOT}/luat/modules/luat_lib_gpio.c
  46. ${TOPROOT}/luat/modules/luat_lib_spi.c
  47. ${TOPROOT}/luat/modules/luat_lib_pack.c
  48. ${TOPROOT}/luat/modules/luat_lib_zbuff.c
  49. ${TOPROOT}/luat/modules/luat_lib_mqttcore.c
  50. ${TOPROOT}/luat/modules/luat_lib_libcoap.c
  51. ${TOPROOT}/luat/modules/luat_lib_crypto.c
  52. ${TOPROOT}/components/sfd/luat_lib_sfd.c
  53. ${TOPROOT}/components/sfd/luat_sfd_mem.c
  54. ${TOPROOT}/components/sfd/luat_sfd_w25q.c
  55. ${TOPROOT}/luat/modules/crc.c
  56. ${TOPROOT}/luat/vfs/luat_vfs.c
  57. ${TOPROOT}/luat/vfs/luat_fs_luadb.c
  58. ${TOPROOT}/luat/vfs/luat_fs_posix.c
  59. ${TOPROOT}/luat/vfs/luat_fs_lfs2.c
  60. ${TOPROOT}/luat/vfs/luat_luadb_inline.c
  61. ${TOPROOT}/luat/vfs/luat_luadb_inline_sys.c
  62. ${TOPROOT}/luat/vfs/luat_inline_sys.c
  63. ${TOPROOT}/luat/packages/lfs/lfs_sfd.c
  64. ${TOPROOT}/luat/packages/lfs/lfs_util.c
  65. ${TOPROOT}/luat/packages/lfs/lfs.c
  66. ${TOPROOT}/luat/packages/lfs/luat_lib_lfs2.c
  67. # ${LCD_SRCS}
  68. )
  69. IF (WIN32)
  70. #-----------------------
  71. # LuaFileSystem --> lfs
  72. aux_source_directory(./rock/LuaFileSystem ROCK_LFS_SRCS)
  73. add_library(rock_lfs ${ROCK_LFS_SRCS})
  74. #-----------------------
  75. #------------------------
  76. # librs232 -> rs232
  77. include_directories(./rock/librs232/include)
  78. aux_source_directory(./rock/librs232/src ROCK_LIB_RS232_SRCS)
  79. add_library(rock_librs232 ${ROCK_LIB_RS232_SRCS} ./rock/librs232/bindings/lua/luars232.c)
  80. #------------------------
  81. ENDIF ()
  82. include_directories(${TOPROOT}/luat/packages/fatfs)
  83. add_library(fatfs ${TOPROOT}/luat/packages/fatfs/ff.c
  84. ${TOPROOT}/luat/packages/fatfs/ffsystem.c
  85. ${TOPROOT}/luat/packages/fatfs/ffunicode.c
  86. ${TOPROOT}/luat/packages/fatfs/diskio_impl.c
  87. ${TOPROOT}/luat/packages/fatfs/diskio_ramdisk.c
  88. ${TOPROOT}/luat/packages/fatfs/diskio_spitf.c
  89. ${TOPROOT}/luat/vfs/luat_fs_fatfs.c
  90. ${TOPROOT}/luat/packages/fatfs/luat_lib_fatfs.c)
  91. #-----------------------
  92. # mbedtls
  93. include_directories(${TOPROOT}/components/mbedtls/include)
  94. add_subdirectory(${TOPROOT}/components/mbedtls mbedtls.out)
  95. #-----------------------
  96. #-----------------------
  97. # lvgl
  98. include_directories(${TOPROOT}/components/lvgl)
  99. add_subdirectory(${TOPROOT}/components/lvgl lvgl.out)
  100. #-----------------------
  101. #-----------------------
  102. # lwip
  103. # include_directories(${TOPROOT}/components/network/lwip)
  104. # add_subdirectory(${TOPROOT}/components/network/lwip lwip.out)
  105. #-----------------------
  106. IF (WIN32)
  107. # 指定生成目标
  108. add_executable(luatos src/main_win32.c)
  109. target_link_libraries(luat freertos10 winmm fatfs lvgl
  110. # lwip
  111. )
  112. target_link_libraries(luatos freertos10 lua luatos_msys luat winmm cjson
  113. rock_lfs rock_librs232 mbedtls fatfs lvgl
  114. # lwip
  115. # lwipcontribexamples lwipcontribapps lwipcontribaddons
  116. # lwipallapps lwipcore lwipcontribportwindows lwipmbedtls
  117. )
  118. ELSE ()
  119. add_executable(luatos src/main_posix.c)
  120. target_link_libraries(luat freertos10 pthread fatfs lvgl)
  121. target_link_libraries(luatos freertos10 lua luatos_msys fatfs luat pthread cjson mbedtls lvgl m)
  122. ENDIF ()