1e5c31af7Sopenharmony_ciadd_definitions(-DDE_OS="DE_OS_UNIX") 2e5c31af7Sopenharmony_ciadd_definitions(-DDE_COMPILER="DE_COMPILER_CLANG") 3e5c31af7Sopenharmony_ciadd_definitions(-DDE_CPU="DE_CPU_ARM") 4e5c31af7Sopenharmony_ci 5e5c31af7Sopenharmony_ciset(CMAKE_CROSSCOMPILING TRUE) 6e5c31af7Sopenharmony_ciset(CMAKE_SYSTEM_NAME Linux) 7e5c31af7Sopenharmony_ciset(CMAKE_CXX_COMPILER_ID Clang) 8e5c31af7Sopenharmony_ciSET ( CMAKE_SYSTEM_PROCESSOR arm ) 9e5c31af7Sopenharmony_ci 10e5c31af7Sopenharmony_ciadd_definitions(-DFE_TONEAREST=0x00000000) 11e5c31af7Sopenharmony_ciadd_definitions(-DFE_UPWARD=0x00400000) 12e5c31af7Sopenharmony_ciadd_definitions(-DFE_DOWNWARD=0x00800000) 13e5c31af7Sopenharmony_ciadd_definitions(-DFE_TOWARDZERO=0x00c00000) 14e5c31af7Sopenharmony_ci#add_definitions(-D_XOPEN_SOURCE=600) 15e5c31af7Sopenharmony_ci 16e5c31af7Sopenharmony_ciSET ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) 17e5c31af7Sopenharmony_ciSET ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) 18e5c31af7Sopenharmony_ciSET ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) 19e5c31af7Sopenharmony_ci 20e5c31af7Sopenharmony_ciSET ( CROSS_COMPILATION_ARCHITECTURE armv7-a ) 21e5c31af7Sopenharmony_ci 22e5c31af7Sopenharmony_ciset(CMAKE_TOOLCHAIN_PREFIX llvm-) 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ciset(PROJECT_ROOT /home/zhangsz/OpenHarmony_master_0625) 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_ci#指定c编译工具(确保工具链所在路径已经添加到了PATH环境变量中)和编译标志,使用clang编译时标志中必须指定--target,否则无法交叉编译。 28e5c31af7Sopenharmony_ciset(CMAKE_C_COMPILER ${PROJECT_ROOT}/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang) 29e5c31af7Sopenharmony_ciset(CMAKE_C_FLAGS "--target=arm-linux-ohosmusl -D__clang__ -march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 -w") 30e5c31af7Sopenharmony_ci#指定c++编译工具(确保工具链所在路径已经添加到了PATH环境变量中)和编译标志,必须指定--target,否则无法交叉编译。 31e5c31af7Sopenharmony_ciset(CMAKE_CXX_COMPILER ${PROJECT_ROOT}/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++) 32e5c31af7Sopenharmony_ciset(CMAKE_CXX_FLAGS "--target=arm-linux-ohosmusl -D__clang__ -march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 -w") 33e5c31af7Sopenharmony_ci#指定链接工具和链接标志,必须指定--target和--sysroot,其中OHOS_ROOT_PATH可通过cmake命令后缀参数来指定。 34e5c31af7Sopenharmony_ciset(MY_LINK_FLAGS "--target=arm-linux-ohosmusl --sysroot=${PROJECT_ROOT}/out/rk3568/obj/third_party/musl/") 35e5c31af7Sopenharmony_ciset(CMAKE_LINKER ${PROJECT_ROOT}/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang) 36e5c31af7Sopenharmony_ciset(CMAKE_CXX_LINKER ${PROJECT_ROOT}/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++) 37e5c31af7Sopenharmony_ciset(CMAKE_C_LINKER ${PROJECT_ROOT}/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang) 38e5c31af7Sopenharmony_ci 39e5c31af7Sopenharmony_ci#指定链接库的查找路径。 40e5c31af7Sopenharmony_ciset(CMAKE_SYSROOT ${PROJECT_ROOT}/out/rk3568/obj/third_party/musl/) 41e5c31af7Sopenharmony_ciset(CMAKE_EXE_LINKER_FLAGS "-Wl,--dynamic-linker,/system/bin/ld-musl-arm.so.1") 42