How to create a CMakeLists.txt in order to compile a PNaCl program?

790 views Asked by At

I have a PNaCl program that I'm trying to compile using CMake.

I included the following lines but doest not work at all:

# 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)

Error printing: pnacl-ld: Unrecognized option: -search_paths_first

2

There are 2 answers

0
Renan Grativol On BEST ANSWER

Based on Derek's answer: set(CMAKE_SYSTEM_NAME "Generic" CACHE STRING "Target system.")

Otherwise, CMAKE will use specific flag.

2
Derek On

-search_paths_first seems to be an OSX-specific flag, so it seems that CMake isn't aware you are doing a cross build. As far as I know it is not necessary to force the compiler; setting CMAKE_C_COMPILER and the other tools might be sufficient. If there are still issues you might also try setting CMAKE_SYSTEM_NAME=nacl