[CMake] OS X, embedding Frameworks and generator problems

Werner Smekal smekal at iap.tuwien.ac.at
Fri Mar 5 08:55:50 EST 2010


Hi Francisco,

for the SDL Framework (downloaded from libsdl.org) you don't need the
bundleUtilities, so don't use it (in fact it doesn't work as you also
found out). If you just don't copy anything, then the app should just
work (assumed, that you SDL Framework is either in /Libraries/Framework
or /Users/user/Libraries/Framework.

Test this. Run the created app. Does it work?

To create an app bundle with framework included, run cmake like that

cmake -DCMAKE_INSTALL_PREFIX=installdir path-to-src

and in CMakeLists.txt add this INSTALL(Directory ..) commands I send you
earlier.

Now when you run "make", an app is created without the Framework. Does
it run? When you do now "make install" an app will be created in
installdir, where the Framework should be included. Does it run? if yes,
copy it to another computer where no SDL is installed and try again.

HTH,
Werner

On 3/5/10 12:58 PM, Francisco Requena wrote:
> Yes, I tried, but without success. 
> 
> My resulting file is: 
> 
> cmake_minimum_required(VERSION 2.8)
> 
> project(openvolt)
> 
> set(APP_NAME "OpenVolt")
> 
> include(FindSDL)
> string(REPLACE "-framework Cocoa" "" SDL_LIBRARY ${SDL_LIBRARY})
> include(FindOpenGL)
> include(BundleUtilities)
> 
> include_directories(${SDL_INCLUDE_DIR})
> 
> add_executable(${APP_NAME} MACOSX_BUNDLE main.cpp)
> 
> target_link_libraries(${APP_NAME} ${SDL_LIBRARY} SDLmain)
> 
> if(APPLE)
>   install(DIRECTORY ${SDL_LIBRARY} DESTINATION
> ${APP_NAME}.app/Contents/Frameworks)
> endif(APPLE)
> 
> However, it doesn't copies the framework. It just does nothing. 
> 
> 2010/3/5 Michael Wild <themiwi at gmail.com <mailto:themiwi at gmail.com>>
> 
>     As Werner Smekal already mentioned
>     (http://www.cmake.org/pipermail/cmake/2010-March/035636.html), for
>     SDL it is apparently not necessary to use BundleUtilities. Have you
>     tried this?
> 
>     Michael
> 
> 
>     On 5. Mar, 2010, at 12:50 , Francisco Requena wrote:
> 
>     > However, I can't get it working. My aim is to make an standalone .app
>     > bundle, distributable with SDL embedded. How should I use
>     BundleUtilities to
>     > get rid of this?
>     >
>     > Thanks.
>     >
>     > 2010/3/5 Michael Wild <themiwi at gmail.com <mailto:themiwi at gmail.com>>
>     >
>     >> http://www.cmake.org/Wiki/BundleUtilitiesExample
>     >>
>     >> Michael
>     >>
>     >> On 5. Mar, 2010, at 9:40 , 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 <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