CMake, Macports, SDL and OSX

I just had a hard time building a simple SDL application using CMake and Macports on Mac OS X. On Linux things are really simple – you ask for SDL, pkg-config returns the right configuration and everything works. Not on OS X.

Using a typical CMake-configuration

pkg_check_modules(SDL sdl)
target_link_libraries(mygame ${SDL_LIBRARIES})

I execute CMake using

cmake -DCMAKE_EXE_LINKER_FLAGS=”-L/opt/local/lib” -DCMAKE_CXX_FLAGS=”-I/opt/local/include” ../src/

and run “make”. This doesn’t work. It turns out you have to link with the Cocoa framework. So obvious, right?

cmake -DCMAKE_EXE_LINKER_FLAGS=”-L/opt/local/lib -framework Cocoa” -DCMAKE_CXX_FLAGS=”-I/opt/local/include” ../src/

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s