Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER for building Assimp for iOS?

Tags:

ios

cmake

When I try to build Assimp by running build_ios.sh, it tells me:

CMake Error: your C compiler: "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc" was not found.   Please set CMAKE_C_COMPILER to a valid compiler path or name. CMake Error: your CXX compiler: "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name. 

What I need the path to be is:

/Applications/XCode.app/Contents/Developer/Platforms/... 

I've tried changing DEVROOT in build_ios.sh and IPHONE_xxxx_TOOLCHAIN.cmake, because that's what CMAKE_C_COMPILER etc seem to get generated from, but it still gives me the same errors.

like image 289
Curyous Avatar asked Jul 21 '12 01:07

Curyous


2 Answers

Option 1:

You can set CMake variables at command line like this:

cmake -D CMAKE_C_COMPILER="/path/to/your/c/compiler/executable" -D CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable" /path/to/directory/containing/CMakeLists.txt 

See this to learn how to create a CMake cache entry.


Option 2:

In your shell script build_ios.sh you can set environment variables CC and CXX to point to your C and C++ compiler executable respectively, example:

export CC=/path/to/your/c/compiler/executable export CXX=/path/to/your/cpp/compiler/executable cmake /path/to/directory/containing/CMakeLists.txt 

Option 3:

Edit the CMakeLists.txt file of "Assimp": Add these lines at the top (must be added before you use project() or enable_language() command)

set(CMAKE_C_COMPILER "/path/to/your/c/compiler/executable") set(CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable") 

See this to learn how to use set command in CMake. Also this is a useful resource for understanding use of some of the common CMake variables.


Here is the relevant entry from the official FAQ: https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler

like image 145
abi Avatar answered Sep 22 '22 22:09

abi


The cc and cxx is located inside /Applications/Xcode.app. This should find the right paths

export CXX=`xcrun -find c++` export CC=`xcrun -find cc` 
like image 22
neoneye Avatar answered Sep 23 '22 22:09

neoneye