Building an iOS app with cmake

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
User avatar
affentanz
Kobold
Posts: 30
Joined: Tue Sep 03, 2013 10:34 pm
x 2

Building an iOS app with cmake

Post by affentanz »

I'm trying to build my ogre application for ios with cmake. Does anybody have experience with that?

I'm done with building "ogre samples" for ios. And the "sample browser" runs in ios simulator and on an ipad.
Then I've made a simple application with ogre that runs already on desktop platforms. Now I want to write a CMake Makefile that can generate a XCode iOS Project out of my code. I've looked in the Sample Browser Code but I didn't get it.

In the moment cmake stucks at finding ogre. What should I write in the CMAKE_MODULE_PATH? The path to the sample browser ios build didn't work. Here the whole cmake error message:
CMake Error at CMakeLists.txt:37 (find_package):
By not providing "FindOGRE.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "OGRE", but CMake did not find one.

Could not find a package configuration file provided by "OGRE" with any of the following names:

OGREConfig.cmake
ogre-config.cmake

Add the installation prefix of "OGRE" to CMAKE_PREFIX_PATH or set "OGRE_DIR" to a directory containing one of the above files. If "OGRE" provides a separate development package or SDK, be sure it has been installed.
In line 37 is: find_package(OGRE REQUIRED)
User avatar
affentanz
Kobold
Posts: 30
Joined: Tue Sep 03, 2013 10:34 pm
x 2

Re: Building an iOS app with cmake

Post by affentanz »

Maybe this is the better question: How do I compile ogre as a (shared or static) library for iOS?
User avatar
affentanz
Kobold
Posts: 30
Joined: Tue Sep 03, 2013 10:34 pm
x 2

Re: Building an iOS app with cmake

Post by affentanz »

For everyone with the same problem: The answer to my first post is to write the following in your CMakeLists.txt:

Code: Select all

set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OGRE_ROOT}/CMake/Packages ${OGRE_ROOT}/CMake/Utils)
${OGRE_ROOT} has to be the correct path to the root directory of the ogre source code (when compiling ogre yourself). If you use the OgreSDK for iOS from the download page, you have to write:

Code: Select all

set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OGRE_ROOT}/CMake)
But now I've got the following error message:
-- Could not locate OGRE
CMake Error at /XXX/OgreSDK/CMake/FindPkgMacros.cmake:120 (message):
Required library OGRE not found! Install the library (including dev
packages) and try again. If the library is already installed, set the
missing variables manually in cmake.
Call Stack (most recent call first):
/XXX/OgreSDK/CMake/FindOGRE.cmake:245 (findpkg_finish)
CMakeLists.txt:43 (find_package)
No matter if I use the SDK or the source.
User avatar
affentanz
Kobold
Posts: 30
Joined: Tue Sep 03, 2013 10:34 pm
x 2

Re: Building an iOS app with cmake

Post by affentanz »

Sorry for so many posts!

Can someone help me with my problem? I found out that in FindOGRE.cmake the "OGRE_INCLUDE_DIR" variable isn't set. I think this variable should be set after this

Code: Select all

set(OGRE_RESET_VARS 
  OGRE_CONFIG_INCLUDE_DIR OGRE_INCLUDE_DIR 
  OGRE_LIBRARY_FWK OGRE_LIBRARY_REL OGRE_LIBRARY_DBG
  OGRE_PLUGIN_DIR_DBG OGRE_PLUGIN_DIR_REL OGRE_MEDIA_DIR)
and this

Code: Select all

find_path(OGRE_INCLUDE_DIR NAMES OgreRoot.h HINTS ${OGRE_CONFIG_INCLUDE_DIR} ${OGRE_INC_SEARCH_PATH} ${OGRE_FRAMEWORK_INCLUDES} ${OGRE_PKGC_INCLUDE_DIRS} PATH_SUFFIXES "OGRE")
But it is not. So the "if (OGRE_INCLUDE_DIR)" in line 183 (maybe it's a different line in your FindOGRE.cmake version) is false and OGRE is not found. Does anybody know why this could happen?
User avatar
affentanz
Kobold
Posts: 30
Joined: Tue Sep 03, 2013 10:34 pm
x 2

Re: Building an iOS app with cmake

Post by affentanz »

I think the ogre cmake build system is broken for iOS.

I fixed the OGRE_INCLUDE_DIR error from my last post with defining "set(OGRE_INCLUDE_DIR ${OGRE_SOURCE}/OgreMain/include)" in my CMakeLists.txt. But that's not a clean solution and now I've got the next problem:

Code: Select all

-- Looking for OGRE...
-- Found Ogre Ghadamon (1.9.0)
-- Build type (static, dynamic) does not match the requested one.
-- Could not locate OGRE
CMake Error at /.../ogresource/CMake/Utils/FindPkgMacros.cmake:120 (message):
  Required library OGRE not found! Install the library (including dev
  packages) and try again.  If the library is already installed, set the
  missing variables manually in cmake.
Call Stack (most recent call first):
  /.../ogresource/CMake/Packages/FindOGRE.cmake:245 (findpkg_finish)
  CMakeLists.txt:55 (find_package)
I don't know what "-- Build type (static, dynamic) does not match the requested one." should mean. I've set OGRE_STATIC to TRUE in my CMakeLists.txt because iOS needs static libraries.

EDIT: Really sorry for posting so many posts. I could fix the "static error" with defining "set(OGRE_CONFIG_INCLUDE_DIR ${OGRE_BUILD}/include)" in my CMakeLists.txt file. But there's still the "Could not locate OGRE" message.

(Even if nobody answers here, maybe this will be helpful for someone in the future having the same problems...)