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
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/