首先目标平台是OpenWrt系统
VScode 是linux Ubuntu版本
VSCode 安装CMake CMake-tool
ctrl shift p 输入CMake:QuickStart
输入工程名回车
会创建一个CMakeList.txt ,我们需要更改下这个文件,来包含我的工程源码和指定交叉编译工具,我的配置如下:
cmake_minimum_required(VERSION 3.0.0)
project(nfc_reader_gui VERSION 0.1.0)
include(CTest)
enable_testing()
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
SET(CMAKE_C_COMPILER "/home/huangea/openwrt_widora/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-uclibc-gcc-4.8.3")
add_compile_options(-std=c99)
file(GLOB_RECURSE INCLUDES "lv_drivers/*.h" "lv_examples/*.h" "lvgl/*.h" "./*.h" )
file(GLOB_RECURSE SOURCES "lv_drivers/*.c" "lv_examples/*.c" "lvgl/*.c" )
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
find_package(SDL2 REQUIRED SDL2)
include_directories(${SDL2_INCLUDE_DIRS})
add_executable(nfc_reader_gui main.c ${SOURCES} ${INCLUDES})
target_link_libraries(nfc_reader_gui PRIVATE )
add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/main)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
然后cmake CMakeList.txt 之后 直接 make 就可以了