cmake 交叉编译设置

发布时间 2024-01-10 19:55:11作者: *^VV^*

cmake_minimum_required(VERSION 3.1)

#设置交叉编译
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(TOOLCHAIN_DIR "/usr/local/lib/gcc-linaro-7.5")
SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_DIR})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SET(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/arm-linux-gnueabihf-g++)

#工程设置
project(demo)
add_compile_options(-Wall)

#添加路径
include_directories(. ./source /usr/local/include)
add_subdirectory(lvgl)
add_subdirectory(source)
add_subdirectory(lv_drivers)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../)
add_executable(${PROJECT_NAME} main.c)
target_link_libraries(${PROJECT_NAME} PRIVATE lvgl lvgl::drivers source pthread)