commit
3c19385e56
@ -0,0 +1,28 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
|
||||||
|
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/arm.linux.toolchain.cmake)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
project(cross_test)
|
||||||
|
|
||||||
|
add_executable(cross_test main.cpp)
|
||||||
|
|
||||||
|
|
||||||
|
#set(CMAKE_PREFIX_PATH $ENV{QT_HOME})
|
||||||
|
#
|
||||||
|
#find_package(Qt6 COMPONENTS
|
||||||
|
# Core
|
||||||
|
# REQUIRED
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
#target_link_libraries(${PROJECT_NAME}
|
||||||
|
# PRIVATE
|
||||||
|
# Qt6::Core
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
#target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
|
# ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
# 设置目标系统、处理器架构
|
||||||
|
set(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||||
|
|
||||||
|
# 设置工具链目录
|
||||||
|
set(TOOL_CHAIN_DIR $ENV{CPP_TOOLCHAIN_ARM_LINUX})
|
||||||
|
|
||||||
|
set(TOOL_CHAIN_INCLUDE ${TOOL_CHAIN_DIR}/aarch64-none-linux-gnu/include ${TOOL_CHAIN_DIR}/aarch64-none-linux-gnu/libc/usr/include)
|
||||||
|
set(TOOL_CHAIN_LIB ${TOOL_CHAIN_DIR}/aarch64-none-linux-gnu/lib ${TOOL_CHAIN_DIR}/aarch64-none-linux-gnu/libc/usr/lib)
|
||||||
|
|
||||||
|
# 设置编译器位置
|
||||||
|
set(CMAKE_C_COMPILER ${TOOL_CHAIN_DIR}/bin/aarch64-none-linux-gnu-gcc.exe)
|
||||||
|
set(CMAKE_CXX_COMPILER ${TOOL_CHAIN_DIR}/bin/aarch64-none-linux-gnu-g++.exe)
|
||||||
|
|
||||||
|
# 设置cmake查找主路径
|
||||||
|
set(CMAKE_FIND_ROOT_PATH ${TOOL_CHAIN_DIR}/aarch64-none-linux-gnu)
|
||||||
|
|
||||||
|
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_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
|
|
||||||
|
# 包含工具链文件
|
||||||
|
include_directories(
|
||||||
|
${TOOL_CHAIN_DIR}/aarch64-none-linux-gnu/include
|
||||||
|
${TOOL_CHAIN_DIR}/aarch64-none-linux-gnu/libc/usr/include)
|
||||||
|
|
||||||
|
# 设置CMAKE_INCLUDE_PATH
|
||||||
|
set(CMAKE_INCLUDE_PATH ${TOOL_CHAIN_INCLUDE})
|
||||||
|
|
||||||
|
# 设置CMAKE_LIBRARY_PATH
|
||||||
|
set(CMAKE_LIBRARY_PATH ${TOOL_CHAIN_LIB})
|
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
set BUILD_PATH=build
|
||||||
|
|
||||||
|
if not exist BUILD_PATH (
|
||||||
|
mkdir BUILD_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
cd BUILD_PATH
|
||||||
|
|
||||||
|
cmake -G "MinGW Makefiles" ..
|
||||||
|
|
||||||
|
# install
|
||||||
|
#mingw32-make
|
@ -0,0 +1,7 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
std::cout << "hello world!" << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in new issue