1.helloworld.c
#include <stdio.h>
int main()
{
printf("Hello World Test!\n");
return 0;
}
2.CMakeLists.txt
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "arm")
set(CMAKE_C_COMPILER "arm-linux-gcc")
set(CMAKE_CXX_COMPILER "arm-linux-g++")
project(hello_jelly)
set(APP_SRC main.c)
add_executable(${PROJECT_NAME} main.c)
message(${PROJECT_SOURCE_DIR})
3.cmake
mkdir build
cd build
cmake ..
make
4.运行
./hello_jelly

5.CMakeLists.txt 通用版
project( main )
cmake_minimum_required(VERSION 2.8)
include_directories(/usr/local/include /usr/local/include/opencv /usr/local/include/opencv2)
link_directories(/usr/local/lib)
aux_source_directory(. DIR_SRCS)
add_executable(main ${DIR_SRCS})
target_link_libraries( main -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio -lopencv_video)
指定arm-gcc
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TOOLCHAIN_DIR /opt/toolchain/aarch64-rockchip1031-linux-gnu)
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-none-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-none-linux-gnu-g++)
example
# 父目录下的CMakeLists.txt
project(main)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "arm")
set(CMAKE_C_COMPILER "aarch64-none-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "aarch64-none-linux-gnu-g++")
set(current_dir "${CMAKE_CURRENT_SOURCE_DIR}")
#添加头文件路径
include_directories(${current_dir}/include)
#添加库文件路径
link_directories(${current_dir}/lib)
add_executable(main test.c)
target_link_libraries( main -lusb-1.0)