[CMake] Fwd: Re: Need cmake help for MacOsX
Werner Smekal
smekal at iap.tuwien.ac.at
Fri May 21 16:34:39 EDT 2010
[Didn't send to list, so I forward my reply to Jerome.]
-------- Original Message --------
Subject: Re: [CMake] Need cmake help for MacOsX
Date: Fri, 21 May 2010 22:02:42 +0200
From: Werner Smekal <smekal at iap.tuwien.ac.at>
To: Jérôme VERNET <vernet.jerome at wanadoo.fr>
Hi Jerome,
On 5/21/10 4:42 PM, Jérôme VERNET wrote:
>
> Hi,
>
> I'm trying to update an existing cmake project to be used on MacOsX.
> After a lot of thinking, I can now build, using the right
> framworks/library/using the good SDK/on the right ARCHitecture... It was
> hard, because there is nearly no MacOsX cmake documentation (or not up
> to date).
There is no section in the cmake documentation especially for Mac OS X,
but all options, etc. also especially for Mac OS X are documented
(nearly all ;) and you can read through the mailing list and wiki to
find most of your questions answered.
>
> The last thing I'm stucked on is:
> - how can cmake copy some Frameworks in the Ressources folder of my
> bundled app ? I need to copy SDL.Framework, for example.
As Michael already wrote SDL is special, since the SDL framework doesn't
need to be "fixed", only copied into the application bundle, this is
what I do:
# copy SDL frameworks into app bundle for Mac OS X
if(APPLE)
INSTALL(DIRECTORY /Users/smekal/Library/Frameworks/SDL.framework
DESTINATION xrick.app/Contents/Frameworks)
INSTALL(DIRECTORY /Users/smekal/Library/Frameworks/SDL_mixer.framework
DESTINATION xrick.app/Contents/Frameworks)
INSTALL(DIRECTORY /Users/smekal/Library/Frameworks/SDL_ttf.framework
DESTINATION xrick.app/Contents/Frameworks)
endif(APPLE)
It's not nice that the path to the SDL framework is hard coded, but it
works right now and will change later. Obviously, you need to run "make
install" to get the correct application bundle and I usually set the
prefix path to a temporary directory, e.g.
cmake -DCMAKE_INSTALL_PREFIX=path-to-temp ..
or similar.
> - how can cmake can copy my localized resources (French.lproj and
> English.lproj) in my bundled app ?
> I tried this:
>
> # When building for OSX, define specific sources for gui and ressources
> if(ENABLE_OSX_BUNDLE)
> set(GUIOSX_SOURCES
>
> gui-osx/AlertHooks.m gui-osx/PrefsController.m gui-osx/Shared.m
>
> gui-osx/CreateFloppyController.m gui-osx/SDLMain.m)
>
> set_source_files_properties(${GUIOSX_SOURCES} PROPERTIES LANGUAGE C)
>
> set(GUIOSX_RSRCS
> gui-osx/Hatari.icns
> gui-osx/English.lproj gui-osx/French.lproj)
>
> endif(ENABLE_OSX_BUNDLE)
>
> But I have an error about Copying gui-osx/English.lproj at the end....
I don't know where the localized resource should go into (resource
directory?), but again e.g. I do:
if(APPLE)
add_executable(
xrick MACOSX_BUNDLE
${xrick_SRCS}
${xrick_data}
${xrick_RSRCS}
)
# Mac OS X bundle specific settings
set(MACOSX_BUNDLE true)
set(MACOSX_BUNDLE_BUNDLE_NAME xrick)
set(MACOSX_BUNDLE_INFO_STRING "xrick ${xrick_VERSION}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${xrick_VERSION}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${xrick_VERSION}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${xrick_VERSION}")
set(MACOSX_BUNDLE_ICON_FILE xrick.icns)
# paths for data files in bundle
set_source_files_properties(
${xrick_RSRCS}
PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set_source_files_properties(
${xrick_data}
PROPERTIES
MACOSX_PACKAGE_LOCATION MacOS
)
endif(APPLE)
Resources etc. get copied in to the app bundle "automatically".
>
> For the second point, it was working when there is only one file, but
> now, there is folder to be copied.
>
> What about "fixBundle" ? I wcannot find any documentation....
Read the BundleUtilities.cmake module in the cmake.app - there is a lot
of documentation. Short example
# fixup bundle, copy dynamic libraries into app bundle
set(APPS "\${CMAKE_INSTALL_PREFIX}/${SESSA_BUNDLE_NAME}.app") # paths
to executables
set(DIRS "${CMAKE_SOURCE_DIR}/local/Release/lib") # directories to
search for prerequisites
INSTALL(CODE "
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
")
The bundle is "fixed" when running "make install", just running make is
not enough. Again use CMAKE_INSTALL_PREFIX so that the bundle is
installed in a directory where you want it.
> Next thing i will need help:
> - I will have a problem that I cannot yet resolve: building an i386 app
> for debbugging, and an Universal (x86;ppc) for Release... Tried without
> success... I read a previous thread in this mailing list, but cannot
> find a solution.
make two build directories. in one run cmake with
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 ..
and in the other
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=i386;ppc ..
done. Ctrl-r in bash is your friend to get the commands again if you
need them.
HTH,
Werner
> - Make a different build system when building on MacOsX 10.5 or 10.6.
> When using 10.5, I will need to use library that are not provided by
> MacOs 10.5 (readline, libpng, etc) in the good version. So, make will
> have to find them elsewhere or display an error. May be there is a way
> to find a version number ?
> - ....
> Thanks for help,
>
> Jerome
>
> --------------
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
--
Dr. Werner Smekal
Institut fuer Angewandte Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10/134
A-1040 Wien
Austria
DVR-Nr: 0005886
email: smekal at iap.tuwien.ac.at (GPG: EDCAF4A79)
web: http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office)
+43-(0)1-58801-13469 (laboratory)
fax: +43-(0)1-58801-13499
More information about the CMake
mailing list