liamxin 2 years ago
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;
}

@ -0,0 +1,4 @@
# cpp 交叉编译示例
x64 windows for arm linux
Loading…
Cancel
Save