Compiling Capnp on iOS 10.3

222 views
Skip to first unread message

Yacine Alami

unread,
Nov 21, 2017, 1:56:13 PM11/21/17
to Cap'n Proto
Hi guys,

I'm currently working on an iOS app that would require the integration of capnp. 
I'm used to use CMake to cross compile c++ libraries for iOS using an iOS toolchain.
However, for Capnp I'm stuck on some errors and not even able to generate the Xcode project to compile it using the command line.

I'm trying to cross compile capnp as a static lib that I can link and call into my iOS app using an Obj-c++  wrapper to be able to call it from SWIFT.

I use this toolchain (https://github.com/cristeab/ios-cmake) and CMake 9.3, I'm on high Sierra 10.13.1 and the lastest Xcode 9.1.
I'm targeting iOS 10.3 not 11 yet.

Anyone ever managed to compile it on iOS ? Any help would be greatly appreciated!

To give more insight of my problems those are the errors that I get :

CMake Error at c++/src/kj/CMakeLists.txt:63 (target_compile_features):
target_compile_features no known features for CXX compiler

"Clang"

version 9.0.0.9000038.

CMake Error at c++/src/capnp/CMakeLists.txt:182 (install):
install TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable
target "capnp_tool".


I did include the right c++11 flags for iOS (-stdlib=libc++) and add some Apple specific Cmake instruction.

I use AppleClang 9.0.0.9000038 to compile it.


Thanks a lot for your time guys!


Yacine

Philip

unread,
Nov 23, 2017, 3:24:43 PM11/23/17
to Yacine Alami, Cap'n Proto
Hi Yacine,

There are a couple of iOS toolchains for CMake (I've used
https://github.com/leetal/ios-cmake in the past), but none of them
work particularly well with CMake projects that want to check compiler
features – they either select the wrong compiler, or build the feature
test for the wrong platform.

In this case, you can remove the offending "target_compile_features"
line to hack around the toolchain issue. I've also had similarly-hacky
success with generating an Xcode project for macOS and using Xcode to
change the toolchain.

Philip
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to capnproto+...@googlegroups.com.
> Visit this group at https://groups.google.com/group/capnproto.

Yacine Alami

unread,
Nov 27, 2017, 12:43:15 PM11/27/17
to Cap'n Proto
Hi Philip,

Thanks for the answer, I will try the hacky way on commenting out the "target_compile_feature", though I'm afraid it might 'corrupt' the generated library, not sure yet.
I'll try the xcode solution too.

Do you know if there is any plan to officially support iOS soon, or will we be hacking the compilation all the time ?

Thanks!

Philip

unread,
Nov 27, 2017, 11:17:39 PM11/27/17
to Yacine Alami, Cap'n Proto
Unfortunately, I believe these are bugs with the toolchain and not Cap'n Proto.

This commit explains why "target_compile_features" is used:
https://github.com/capnproto/capnproto/commit/1d0d1c3bf56af2935cb229a882ea5c604b1a5f4a

It may be possible to replace target_compile_features with another
test as a workaround, but the real fix is for the toolchain to support
compiler feature detection.

Philip
Reply all
Reply to author
Forward
0 new messages