我有一个PNaCl程序,我尝试使用CMake编译。
我包括以下几行,但根本不起作用:
# disable compiler detection
include(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER("${CMAKE_C_COMPILER}" Clang)
CMAKE_FORCE_CXX_COMPILER("${CMAKE_CXX_COMPILER}" Clang)
# specify cross-compilers
set(NACL_BIN /usr/local/share/nacl_sdk/pepper_43/toolchain/mac_pnacl/bin)
set(CMAKE_C_COMPILER "${NACL_BIN}/pnacl-clang" CACHE PATH "gcc" FORCE)
set(CMAKE_CXX_COMPILER "${NACL_BIN}/pnacl-clang++" CACHE PATH "g++" FORCE)
set(CMAKE_AR "${NACL_BIN}/pnacl-ar" CACHE PATH "archive" FORCE)
set(CMAKE_LINKER "${NACL_BIN}/pnacl-clang++" CACHE PATH "linker" FORCE)
set(CMAKE_RANLIB "${NACL_BIN}/pnacl-ranlib" CACHE PATH "ranlib" FORCE)
打印错误:
pnacl-ld: Unrecognized option: -search_paths_first
答案 0 :(得分:1)
-search_paths_first似乎是一个特定于OSX的标志,所以似乎CMake并不知道你正在进行交叉构建。据我所知,没有必要强制编译器;设置CMAKE_C_COMPILER和其他工具可能就足够了。如果仍有问题,您也可以尝试设置CMAKE_SYSTEM_NAME = nacl
答案 1 :(得分:1)
根据Derek的回答:
set(CMAKE_SYSTEM_NAME "Generic" CACHE STRING "Target system.")
否则,CMAKE将使用特定标志。