[CMake] Adding Core Data model files to a CMake generated Xcode project

James Munro me at jdmunro.net
Thu Dec 8 11:01:33 EST 2011


Just to quickly update on this issue:

I have made some progress, and the file is now included in the generated
project:

# Core Data model.
set (data_model Resources/Data/${NAME}.xcdatamodeld)
set (APP_TYPE MACOSX_BUNDLE)
add_executable (${NAME}
    ${APP_TYPE}
    ${headers}
    ${sources}
    ${resources}
    ${data_model}
    ${PROJECT_SOURCE_DIR}/Source/${NAME}-Prefix.pch
)
set_target_properties (${NAME} PROPERTIES RESOURCE ${resources}
${data_model})

There are still a couple of issues: Xcode doesn't technically recognise it
as the correct filetype, so you don't get to use the built in editor for
this file type. Additionally, it is not added to the project's build
target, I can't work out why. Adding it manually by ticking the relevant
target checkbox causes it to be included and compiled/handled correctly
when running the project.

So there's 2 remaining issues:

1. Xcode doesn't recognise the file type correctly.
2. It is not added to the build target.

I suspect that the Xcode project generator code is simply not aware of this
type of file.

Kind regards

James Munro

On Thu, Dec 8, 2011 at 12:47 PM, James Munro <me at jdmunro.net> wrote:

> Hi there,
>
> I use CMake as part of a project configuration system with several other
> developers. We are very happy with this and it works well for our needs,
> however I recently stumbled on a problem and I'm looking for guidance.
> Normally I can easily add source files and resources that must appear in
> the generated project, but I'm currently struggling to correctly configure
> this for an Xcode-produced Core Data data model file.
>
> Xcode normally treats this as a file, but it in fact just a directory with
> a file extension (similar to an Xcode project file itself):
>
> AppName.xcdatamodeld/
> - AppName.xcdatamodel/
>   - contents (file without an extension)
>
> I'm not that experienced with CMake, and so far I've only tried to add
> them by doing a file() GLOB_RECURSE within the directory where this file
> resides. The files are then added to the project with add_executable.
> However, Xcode has the individual files but does not recognise it as a Core
> Data model file, which is essential for editing this file with the editor.
> It is also not included correctly when compiling the project.
>
> Has anybody solved this problem before, or can perhaps point me in the
> correct direction?
>
> Kind regards
> James Munro
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111208/a113a00c/attachment.htm>


More information about the CMake mailing list