riscv64-clang.toolchain.cmake 1.4 KB

123456789101112131415161718192021222324252627282930
  1. set(CMAKE_SYSTEM_NAME Linux)
  2. set(CMAKE_SYSTEM_PROCESSOR riscv64)
  3. set(RISCV_CLANG_BUILD_ROOT /opt/rvv-llvm CACHE PATH "Path to CLANG for RISC-V cross compiler build directory")
  4. set(RISCV_GCC_INSTALL_ROOT /opt/RISCV CACHE PATH "Path to GCC for RISC-V cross compiler installation directory")
  5. set(CMAKE_SYSROOT ${RISCV_GCC_INSTALL_ROOT}/sysroot CACHE PATH "RISC-V sysroot")
  6. set(CLANG_TARGET_TRIPLE riscv64-unknown-linux-gnu)
  7. set(CMAKE_C_COMPILER ${RISCV_CLANG_BUILD_ROOT}/bin/clang)
  8. set(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET_TRIPLE})
  9. set(CMAKE_CXX_COMPILER ${RISCV_CLANG_BUILD_ROOT}/bin/clang++)
  10. set(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET_TRIPLE})
  11. set(CMAKE_ASM_COMPILER ${RISCV_CLANG_BUILD_ROOT}/bin/clang)
  12. set(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET_TRIPLE})
  13. # Don't run the linker on compiler check
  14. set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
  15. set(CMAKE_C_FLAGS "-march=rv64gcv0p10 -menable-experimental-extensions --gcc-toolchain=${RISCV_GCC_INSTALL_ROOT} -w ${CMAKE_C_FLAGS}")
  16. set(CMAKE_CXX_FLAGS "-march=rv64gcv0p10 -menable-experimental-extensions --gcc-toolchain=${RISCV_GCC_INSTALL_ROOT} -w ${CXX_FLAGS}")
  17. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
  18. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
  19. set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
  20. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  21. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  22. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  23. set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)