I'm trying to integrate SFML2 into my own CMake process on Mac/OSX Lion with the latest XCode. Here is my CMakeLists.txt:
# SFML
add_subdirectory(${SFML_ROOT_PATH})
include_directories(${SFML_ROOT_PATH}/include)
# MyProject
...
add_executable(myproject WIN32 MACOSX_BUNDLE ${MYPROJECT_FILES} )
target_link_libraries(myproject sfml-system sfml-window sfml-audio)
I am using static compilation.
MyProject then has a Main.cpp that includes <SFML/system.hpp> and makes the SFML timer work reliably. It is awesome and clean.
However, using <SFML/audio.hpp> compilation fails because it can't use or find some proper library (OpenAL or libsndfile?) and complains about unreferenced symbols.
Here is the error Message XCode throws at me:
Ld /Users/myusername/Documents/Awesome_CMake/bin/Debug/myexecutable.app/Contents/MacOS/myexecutable normal x86_64
cd /Users/myusername/Dropbox/Awesome_Trunk
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/llvm-g++-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Users/myusername/Documents/Awesome_CMake/bin/Debug -F/Users/myusername/Documents/Awesome_CMake/bin/Debug -F/Applications -filelist /Users/myusername/Documents/Awesome_CMake/Awesome.build/Debug/myexecutable.build/Objects-normal/x86_64/myexecutable.LinkFileList -mmacosx-version-min=10.7 -Wl,-search_paths_first -Wl,-headerpad_max_install_names /Users/myusername/Documents/Awesome_CMake/libs/SFML-b9b3888/lib/Debug/libsfml-system-s-d.a /Users/myusername/Documents/Awesome_CMake/libs/SFML-b9b3888/lib/Debug/libsfml-window-s-d.a /Users/myusername/Documents/Awesome_CMake/libs/SFML-b9b3888/lib/Debug/libsfml-audio-s-d.a /Users/myusername/Documents/Awesome_CMake/libs/SFML-b9b3888/lib/Debug/libsfml-system-s-d.a -o /Users/myusername/Documents/Awesome_CMake/bin/Debug/myexecutable.app/Contents/MacOS/myexecutable
Undefined symbols for architecture x86_64:
"_alGetError", referenced from:
sf::priv::ALCheckError(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)in libsfml-audio-s-d.a(ALCheck.o)
"_alGetEnumValue", referenced from:
sf::priv::AudioDevice::GetFormatFromChannelsCount(unsigned int)in libsfml-audio-s-d.a(AudioDevice.o)
"_alcIsExtensionPresent", referenced from:
sf::priv::AudioDevice::IsExtensionSupported(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in libsfml-audio-s-d.a(AudioDevice.o)
...
To fix this on Windows, I'd probably just have to copy the needed .dlls somewhere and be done with it. But I have no idea what to do on a Mac. Do I have to tell CMake something special so that it finds the precompiled libraries you provide? I'd rather not manually copy libraries/frameworks around on my harddrive because I work with multiple Macs that are not mine and I have to keep it portable.
Thank you in advance for any help.
I'm really stumped here. :oops: