[CMake] Can CMake target different platforms for sub-projects?

Saad Khattak saadrustam at gmail.com
Mon May 13 15:09:13 EDT 2013


Hi,

I currently have a CMake project with multiple sub-projects where
the sub-projects are libraries and executables. The project works on
windows and iOS (via XCode). One such sub-project is an executable that can
only be run on OSX and must be run after every build. This executable makes
a few changes to a couple of source files automatically (mainly for
tracking build related information which is automatically generated). To
ensure that it runs after every build, a custom target is built which
simply runs the previously mentioned exectuable.

Currently, for building iOS libraries and executables, I have the following
set in the root CMakeLists

set(CMAKE_OSX_SYSROOT iphoneos)

With the above line, in XCode I get the iOS targets. What I would like to
know is if CMake will be able to mix iOS and OSX targets? I am aware that I
create a new CMake project just for this, but then the executable will not
be automatically run each time the main project is built.

A little hierarchy to make things easier to understand

MainProject
  +- Library1 (compiles on iOS)
  +- Library2 (compiles on iOS)
  +- Executable1 (compiles on iOS but does not run on iOS - it must be run
automatically when MainProject is built)
  +- Executable2 (compiles/runs on iOS)
  +- ToolExecutable1 (runs the executable built by Executable1 - again,
Executable1 must be built for OSX only)



More information about the CMake mailing list