[CMake] OS X, embedding Frameworks and generator problems

Werner Smekal smekal at iap.tuwien.ac.at
Fri Mar 5 03:59:06 EST 2010


For the SDL Framework it is sufficient to just copy it during the
installation process, e.g. I do

# copy SDL frameworks into app bundle for Mac OS X
if(APPLE)
	INSTALL(DIRECTORY /Users/smekal/Library/Frameworks/SDL.framework
					DESTINATION hex-a-hop.app/Contents/Frameworks)
	INSTALL(DIRECTORY /Users/smekal/Library/Frameworks/SDL_mixer.framework
					DESTINATION hex-a-hop.app/Contents/Frameworks)
	INSTALL(DIRECTORY /Users/smekal/Library/Frameworks/SDL_ttf.framework
					DESTINATION hex-a-hop.app/Contents/Frameworks)
endif(APPLE)

BundeUtilites won't work (as posted before), since the SDL libraries
already have "@executable/../Framework/..." as a reference (use otool -L
on the SDL library) and BundleUtilities then doesn't know where to find
the SDL library (since if the executable is linked to that library it
uses the reference found in the library). But you also don't need to
copy the SDL Framework if you just want to run the app on your
development machine, since if the library isn't found in the app it
looks in /Library and /Users/user/Library to find the framework. But if
you want to give the app to someone else, you need to just copy the SDL
framework in the right place - best done during the install step. This
is a special case, usually BundleUtilities does a perfect job.

HTH,
Werner


On 3/5/10 9:40 AM, Francisco Requena wrote:
> So how do I embeed a framework on an OS X bundle?
> Jjgod Jiang has the same problem
> here: http://www.cmake.org/pipermail/cmake/2009-September/031713.html
> 
> 2010/3/5 David Cole <david.cole at kitware.com <mailto:david.cole at kitware.com>>
> 
>     SDL_library is not a source file, so don't call:
>       set_source_files_properties
>     on it...
> 
>     That should eliminate the spurious content copy attempt...
> 
> 
>     On Thu, Mar 4, 2010 at 6:17 PM, Francisco Requena <the.adx at gmail.com
>     <mailto:the.adx at gmail.com>> wrote:
> 
>         Hi, 
> 
>         I'm trying to develop a simple application using SDL on OS X.
>         Here's my CMakeLists.txt: 
> 
>         cmake_minimum_required(VERSION 2.8)
> 
>         project(newapp)
> 
>         include(FindSDL)
>         include(FindOpenGL)
> 
>         include_directories(${SDL_INCLUDE_DIR})
> 
>         string(REPLACE "-framework Cocoa" "" SDL_LIBRARY ${SDL_LIBRARY})
> 
>         set_source_files_properties(${SDL_LIBRARY} PROPERTIES
>         MACOSX_PACKAGE_LOCATION Frameworks)
> 
>         add_executable(myapp MACOSX_BUNDLE main.cpp ${SDL_LIBRARY})
> 
>         target_link_libraries(myapp ${SDL_LIBRARY} SDLmain "-framework
>         Cocoa")
> 
>         Then I do: 
>         cmake
>         make
> 
>         And that's what I get: 
>         Error copying file "/Library/Frameworks/SDL.framework" to
>         "myapp.app/Contents/Frameworks/SDL.framework".
>         make[2]: *** [myapp.app/Contents/Frameworks/SDL.framework] Error 1
>         make[1]: *** [CMakeFiles/myapp.dir/all] Error 2
>         make: *** [all] Error 2
> 
>         However, if I do: 
>         cmake -G Xcode
> 
>         And then I open the generated Xcode project and do compile, all
>         is working properly. 
>         What should I do?
>         It's just a bug?
> 
>         Thanks,
>         Franciso Requena. 
> 
> 
>         I use the lastest CMake version (git cloned). It's 2.9.20100304.
>         _______________________________________________
>         Powered by www.kitware.com <http://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
> 
> 
> 
> 
> 
> _______________________________________________
> 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