cmake指定交叉編譯

2022-07-22 15:27:25 字數 1071 閱讀 9007

新建檔案arm.cmake,內容如下

#指定嵌入式系統的編譯輸出目錄

set(sysroot_path "/home/suka/out/system")

#指定交叉編譯器路徑

set(toolschain_path "/home/suka/toolschain/")

set(toolchain_host "$usr/bin/arm-linux")

#message("$:$")

message(status "using sysroot path: $")

set(toolchain_cc "$-gcc")

set(toolchain_cxx "$-g++")

#告訴cmake是進行交叉編譯

set(cmake_crosscompiling true)

# define name of the target system

set(cmake_system_name "linux")

# define the compiler

set(cmake_c_compiler $)

set(cmake_cxx_compiler $)

#庫和同標頭檔案查詢的路徑。

set(cmake_find_root_path "$" "$" "$")

# search for programs in the build host directories

set(cmake_find_root_path_mode_program never)

# for libraries and headers in the target directories

set(cmake_find_root_path_mode_library only)

set(cmake_find_root_path_mode_include only)

set(cmake_find_root_path_mode_package only)

啟動使用cmake -dcmake_toolchain_file=arm.cmake -dcmake_install_prefix:filepath=/usr/local

cmake指定交叉編譯

新建檔案arm.cmake,內容如下 指定嵌入式系統的編譯輸出目錄 set sysroot path home suka out system 指定交叉編譯器路徑 set toolschain path home suka toolschain set toolchain host usr bin ...

cmake指定交叉編譯

告知當前使用的是交叉編譯方式,必須配置,cmake system name即目標機target所在的作業系統名稱,比如arm或者linux你就需要寫 linux 如果android平台你就寫 android 如果你的嵌入式平台沒有相關os你即需要寫成 generic set cmake system...

cmake交叉編譯

1 設定交叉編譯之前,必須在 cmakelist.txt 前面加上這樣一句,這樣 cmake 才會認為你是要交叉編譯 set cmake system namelinux 其中linux 是要編譯過去的平台,如果你是在 linux 下交叉編譯 window 的東西,就要寫成 windows 了。我是...