facebookarchive / caffe2

Caffe2 is a lightweight, modular, and scalable deep learning framework.
https://caffe2.ai
Apache License 2.0
8.42k stars 1.95k forks source link

CMake error at third_party/ios-cmake/toolchain/iOS.cmake:151 #419

Open tdp2110 opened 7 years ago

tdp2110 commented 7 years ago

I'm working from https://caffe2.ai/docs/getting-started.html?platform=mac&configuration=compile I successfully built yesterday, but I (foolishly) decided to rebuild today and I get stuck. After downloading the source, I try to run the build script as prescribed:

cd caffe2
./scripts/build_ios.sh

but my output ends with output ends with

Building caffe2
CMake Error at third_party/ios-cmake/toolchain/iOS.cmake:151 (message):
  No iOS SDK's found in default search path .  Manually set
  CMAKE_IOS_SDK_ROOT or install the iOS SDK.
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.8/Modules/CMakeDetermineSystem.cmake:88 (include)
  CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!
./scripts/build_ios.sh  93.36s user 9.78s system 335% cpu 30.773 total

Any ideas? Should this type of question go to a Google Group instead?

I've installed XCode, Automake and Libtool, and I'm working on macOS Sierra version 10.12.4

My copy of Caffe2 is at

00e86ff9 (HEAD -> master, origin/master, origin/HEAD) add gradient for LengthsTileOp

abjurato commented 7 years ago

This error means that ios-cmake tool could not find your Xcode (line 130 https://github.com/Yangqing/ios-cmake/blob/e24081928d9ceec4f4adfcf12293f1e2a20eaedc/toolchain/iOS.cmake). It looks for it via Apple's xcode-select tool, which is part of Xcode Command Line Tools.

Are you sure you've installed both Xcode and Xcode Command Line Tools?

tdp2110 commented 7 years ago

Thanks for the message.

Yeah, I have them:

$ xcode-select -p
/Library/Developer/CommandLineTools
abjurato commented 7 years ago

And do you have any iOS SDKs installed? 🤔

tdp2110 commented 7 years ago

I'm pretty new to all this, so I'm not sure. If XCode installs them by default, then yes?

Does this mean I do?

$ ls /Applications/Xcode.app/Contents/Developer/Platforms/**/SDKs/
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/:
AppleTVOS.sdk     AppleTVOS10.2.sdk

/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/:
AppleTVSimulator.sdk     AppleTVSimulator10.2.sdk

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/:
MacOSX.sdk      MacOSX10.12.sdk

/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/:
WatchOS.sdk    WatchOS3.2.sdk

/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/:
WatchSimulator.sdk    WatchSimulator3.2.sdk

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/:
iPhoneOS.sdk     iPhoneOS10.3.sdk

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/:
iPhoneSimulator.sdk     iPhoneSimulator10.3.sdk
abjurato commented 7 years ago

I didn't dive deep into cmake-ios code, but looks like it is searching SDKs based on xcode-select -p output. Maybe, redirecting xcode-select to your Xcode.app via $ xcode-select -s /Applications/Xcode.app/Contents/Developer will help?

tdp2110 commented 7 years ago

yeah I've been trying to force some of these values but I'm not having much luck

(╯°□°)╯︵ ┻━┻

mjohnst commented 7 years ago

I ran into this issue before. I was able to get around it by adding a line to the cmake args in build_ios.sh:

-DCMAKE_IOS_SDK_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk
tdp2110 commented 7 years ago

@mjohnst: thank you, sir

yitingchiang commented 6 years ago

Hi,

I get the same error message when I execute the setup.sh. Xcode is already installed.

Building caffe2
CMake Error at third_party/ios-cmake/toolchain/iOS.cmake:151 (message):
  No iOS SDK's found in default search path .  Manually set
  CMAKE_IOS_SDK_ROOT or install the iOS SDK.
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.9.4_1/share/cmake/Modules/CMakeDetermineSystem.cmake:94 (include)
  CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!
[Tada!] Done
Yi-tings-Mac:Caffe2-iOS ytc$ 

I have added the CMAKE_IOS_SDK_ROOT into src/caffe2/scripts/build_ios.sh:

cmake .. \
    -DCMAKE_IOS_SDK_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/
    -DCMAKE_TOOLCHAIN_FILE=$CAFFE2_ROOT/third_party/ios-cmake/toolchain/iOS.cmake\
    -DCMAKE_INSTALL_PREFIX=../install \
    -DCMAKE_BUILD_TYPE=Release \
    -DIOS_PLATFORM=${IOS_PLATFORM} \
    -DUSE_CUDA=OFF \
    -DBUILD_TEST=OFF \
    -DBUILD_BINARY=OFF \
    -DCMAKE_C_FLAGS=-fembed-bitcode \
    -DCMAKE_CXX_FLAGS=-fembed-bitcode \
    -DUSE_LMDB=OFF \
    -DUSE_LEVELDB=OFF \
    -DBUILD_PYTHON=OFF \
    -DPROTOBUF_PROTOC_EXECUTABLE=$CAFFE2_ROOT/build_host_protoc/bin/protoc \
    -DCMAKE_VERBOSE_MAKEFILE=1 \
    -DUSE_MPI=OFF \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_THREAD_LIBS_INIT=-lpthread \
    -DCMAKE_HAVE_THREADS_LIBRARY=1 \
    -DCMAKE_USE_PTHREADS_INIT=1 \
    $@ \
    || exit 1

The directory of SDK is as follows:

Yi-tings-Mac:Caffe2-iOS ytc$ ls -al /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/
total 0
drwxrwxr-x  7 root  wheel   238 Oct 13 18:24 .
drwxrwxr-x  4 root  wheel   136 Nov  1 14:28 ..
-rw-rw-r--  1 root  wheel   195 Sep 30 03:33 Entitlements.plist
drwxrwxr-x  3 root  wheel   102 Oct 13 17:43 Library
-rw-rw-r--  1 root  wheel  1011 Sep 30 03:33 SDKSettings.plist
drwxr-xr-x  3 root  wheel   102 Sep 30 10:09 System
drwxr-xr-x  5 root  wheel   170 Oct 13 17:43 usr

The Mac OS version is macOS Sierra 10.12.6, with Xcode version 9.1 and cmake version 3.9.4.

Can anyone help? Thanks!

cclcalder commented 6 years ago

I am having the exact same problem with macOS High Sierra 10.13.1, Xcode version 9.1 and cmake version 3.9.4.

Has there been any solutions for this?

Thanks

yitingchiang commented 6 years ago

Hi, I tried to set the develope directory:

sudo xcode-select --switch /Applications/Xcode.app

and now it works.

I also found that someone set the directory using

xcode-select --switch /Applications/Xcode.app/Contents/Developer

You may try which one works on your machine.