[CMake] Automatic compilation of .xib's for _macosx_ target

Martin Percossi mpercossi at zenaud.io
Wed Apr 29 11:24:30 EDT 2015


Hello,

I came across the following link:

http://stackoverflow.com.80bola.com/questions/7462129/cmake-xib-to-nib-compilation-for-ios-target?s=1|0.8637

Described is how to set up a CMakeLists.txt in order to have .xib files
automatically compiled to .nib files and placed in the Resources folder
within the app bundle for iOS targets. Nice and simple. Unfortunately, I've
tried grafting the relevant parts onto a project that targets Mac OSX, and
while the .xib is copied to the Resources directory, it is not compiled. Do
I need to do it manually, as pointed out elsewhere, if I target OSX?

By the way, I've attached my version of the CMakeLists.txt file. Note that
if I invoke:

cmake -GXcode ..

from a "build" subdirectory, a foo.xcodeproj file is created, as expected,
which "does the right thing". My problem is that I'd like to elide Xcode
and build from the command line. (I'm aware of xcodebuild but I'm curious
if I can do it just using make, because I'd like to build in Clion.)

Many thanks in advance,

Martin Percossi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150429/bc12321a/attachment.html>
-------------- next part --------------
cmake_minimum_required(VERSION 2.8.8)
project(foo)

set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk)
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "macosx")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10)

set(RESOURCES MainMenu.xib)

add_executable(
    foo
    MACOSX_BUNDLE
    AppDelegate.h
    AppDelegate.mm
    main.mm
    ${RESOURCES}
)

set_target_properties(foo PROPERTIES
    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_LIST_DIR}/plist.in
    RESOURCE "${RESOURCES}"
)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AppKit")



More information about the CMake mailing list