On 4/17/14, Aggelos Kolaitis <neoagge...@gmail.com> wrote: > Short: Is linking to Mac OS X frameworks with Xcode generator totally > broken, or am I just doing something wrong? > > Long: I use CMake as the build system for my project[1], and I use > this [2] module to find SDL2 in the user's system. find_library() opts > for the SDL2.framework on Mac OS X, which is located (in my system) in > "/Library/Frameworks/SDL2.framework". In the cache, I can see the > following entries: > > SDL2_INCLUDE_DIR: /Library/Frameworks/SDL2.framework/Headers > SDL2_LIBRARY : /Library/Frameworks/SDL2.framework;-framework Cocoa > > I can successfully generate the Xcode project, but during the build > process, I get an error that 'SDL2: framework not found'. I have > currently found two workarounds: > > 1). Change SDL2_LIBRARY to point to the actual SDL2 library and not > the framework: > > SDL2_LIBRARY : /Library/Frameworks/SDL2.framework/SDL2;-framework > Cocoa > > 2). Use the makefile generator. The error only occurs with Xcode. > > So what is wrong? I can't really test much more on a Mac OS X system > (because I use a friend's Macbook for testing and he's away). This is > CMake 2.8.12, downloaded from the CMake download page. > > Thanks in advance, > Aggelos Kolaitis
I think there is a combination of some things broken in CMake and some things broken with the FindSDL module. We need a new module for SDL2. The trailing -framework Cocoa is a reminder of old hacks that we used to do that I don't think are needed any more. (And now that bundling all assets including frameworks, is even more critical, trying to use SDL2_LIBRARY to list files that need to be bundled won't work as long as it combines build flags with files.) The other problem I've seen is that Apple no longer automatically searches /Library/Frameworks and ~/Library/Frameworks. You need to specify the -F switch, i.e. -F/Library/Frameworks explicitly so the compiler will see your SDL2.framework. I think this needs to be fixed in CMake. (Ironically, I think we removed it a long time ago because it used to cause problems when Apple automatically searched the directory.) Below is my new FindSDL2.cmake replacement. (A work in progress.) find_path(SDL_INCLUDE_DIR NAMES SDL.h PATH_SUFFIXES include/SDL2 include/SDL include DOC "The SDL include directory" ) find_library(SDL_LIBRARY NAMES SDL2 sdl2 SDL sdl2 sdl-2.0 DOC "The SDL library" ) if(WIN32) find_library(SDL_LIBRARY_MAIN NAMES SDL2main sdl2main DOC "The SDLmain library needed on some platforms when builing an application (opposed to a library)" ) else() set(SDL_LIBRARY_MAIN "") endif() # handle the QUIETLY and REQUIRED arguments and set SDL_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR VERSION_VAR SDL_VERSION_STRING) -Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake