4

I have Boost built as a framework for iOS. This is currently installed in Applications/Xcode.app/Contents/Developer/Library/Frameworks/.

When I create a "hand-generated" XCode project, I have no problems using this framework.

I'm now trying to use CMake to generate an XCode project. I found this helpful, cross-compiling toolchain (https://github.com/cristeab/ios-cmake). This works as long as I do not include

find_package( Boost )

But when the above line is added to my CMakeLists.txt file, I get a "Boost_INCLUDE_DIR-NOTFOUND"

So question is: has anyone had success in using CMake with Boost for iOS? If so, any help on how to go about it is greatly appreciated.

I found another SO user trying to do something similar here: How to find a iOS/mac OS X framework via Cmake

But it does not offer much details other than using "CMAKE_FRAMEWORK_PATH".

So any help is much appreciated.

Thanks...

  • Any luck? I was able to use CMAKE_FRAMEWORK_PATH to search where my boost framework was located and find it, but then FindBoost.cmake complains that version.hpp is missing. Boost_NO_BOOST_CMAKE should be able to work around that FindBoost, but it doesn't seem to. – agirault Aug 22 '19 at 12:59

2 Answers2

0

find_package cannot find boost built for ios (tested on cmake 3.13 and 3.14)

Was able to solve it in following way.

Build boost using https://github.com/faithfracture/Apple-Boost-BuildScript

set BOOST_ROOT to Apple-Boost-BuildScript/src/boost_x_xx_x

for iOS:

set(Boost_INCLUDE_DIRS "${BOOST_ROOT}")
set(Boost_LIBRARIES "${BOOST_ROOT}/iphone-build/stage/lib/libboost_date_time.a")
set(Boost_LIBRARIES "${Boost_LIBRARIES};${BOOST_ROOT}/iphone-build/stage/lib/libboost_regex.a")
set(Boost_LIBRARIES "${Boost_LIBRARIES};${BOOST_ROOT}/iphone-build/stage/lib/libboost_system.a")

iOS simulator:

set(Boost_INCLUDE_DIRS "${BOOST_ROOT}")
set(Boost_LIBRARIES "${BOOST_ROOT}/iphonesim-build/stage/lib/libboost_date_time.a")
set(Boost_LIBRARIES "${Boost_LIBRARIES};${BOOST_ROOT}/iphonesim-build/stage/lib/libboost_regex.a")
set(Boost_LIBRARIES "${Boost_LIBRARIES};${BOOST_ROOT}/iphonesim-build/stage/lib/libboost_system.a")
Dmytro
  • 1,290
  • 17
  • 21
0

I hope it's not too late:) I came across almost same issue, find_package always complain that can not find the lib, even the search path is correct, notice that the similar issue also exist for Android NDK

For the ios I suggest:

  1. Enable boost debug by set(Boost_DEBUG ON), then check the path specified is correct or not, ref to this link for more info How can I get CMake to find my alternative Boost installation?

  2. Try find_host_package instead of find_package, I found some clue in ios.cmake which may lead to the issue:

    # only search the iOS sdks, not the remainder of the host filesystem
    set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
    set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
    
Gerry
  • 86
  • 2
  • 13