Hello everyone! First time poster here, so here goes.
...rambling about why I'm doing this goes here, but thoughtfully omitted for your viewing pleasure...Description of ProblemI've been trying to use
cmake to compile a little project of mine on both
Windows 7 and
Fedora 19... and I have run into an apparently common problem:
CMake Error at /usr/share/cmake/Modules/FindSFML.cmake:199 (message):
Could NOT find SFML (missing: SFML_GRAPHICS_LIBRARY SFML_WINDOW_LIBRARY
SFML_SYSTEM_LIBRARY)
Call Stack (most recent call first):
CMakeLists.txt:6 (find_package)
The common answer is that the libs are installed in some non-standard location. But I had already taken extra pains to make sure that they were exactly where they belonged... so something else was wrong.
After inspecting
Laurent's
FindSFML.cmake plugin, and considering why it wasn't finding my libraries, I discovered the problem. Here's a hint: the libraries that
yum installed for me are these:
/usr/lib/libsfml-audio-2.0.so@ /usr/lib/libsfml-graphics.so.2.0* /usr/lib/libsfml-system.so.2@
/usr/lib/libsfml-audio.so.2@ /usr/lib/libsfml-network-2.0.so@ /usr/lib/libsfml-system.so.2.0*
/usr/lib/libsfml-audio.so.2.0* /usr/lib/libsfml-network.so.2@ /usr/lib/libsfml-window-2.0.so@
/usr/lib/libsfml-graphics-2.0.so@ /usr/lib/libsfml-network.so.2.0* /usr/lib/libsfml-window.so.2@
/usr/lib/libsfml-graphics.so.2@ /usr/lib/libsfml-system-2.0.so@ /usr/lib/libsfml-window.so.2.0*
Do you see what is unusual and/or missing about them?
Answer: there is no, eg. "libsfml-audio.so". They all have some
version information attached to them. I suspect this is the common cause of a lot of problems people are reporting about
cmake.
The FixThe issue is on lines 139 and 145 of
FindSFML.cmake. There is only one name given in the NAMES list, and it does not have any version information attached. This may be correct, but as people may have naming stuff added to their default installs (as I did on Fedora), and as is reasonable for SFML 2.x stuff, the fix is to add in names for any possible match. Stuff I considered possible are things like
sfml-audio
sfml-audio-2 sfml-audio2
sfml-audio-2.0 sfml-audio2.0
sfml-audio-20 sfml-audio20
I do not know how to apply for stuff appearing
after .so (nothing should ever appear after .dll or .lib on Windows), but I suspect that ought to cover all cases... though I don't really know enough to say for sure.
In any case, here's the updated portions, starting with line 137:
# debug library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
NAMES ${FIND_SFML_COMPONENT_NAME}-d
${FIND_SFML_COMPONENT_NAME}-d-${SFML_VERSION_MAJOR}
${FIND_SFML_COMPONENT_NAME}-d-${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}
${FIND_SFML_COMPONENT_NAME}-d-${SFML_VERSION_MAJOR}${SFML_VERSION_MINOR}
${FIND_SFML_COMPONENT_NAME}-d${SFML_VERSION_MAJOR}
${FIND_SFML_COMPONENT_NAME}-d${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}
${FIND_SFML_COMPONENT_NAME}-d${SFML_VERSION_MAJOR}${SFML_VERSION_MINOR}
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_LIB_PATHS})
# release library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
NAMES ${FIND_SFML_COMPONENT_NAME}
${FIND_SFML_COMPONENT_NAME}-${SFML_VERSION_MAJOR}
${FIND_SFML_COMPONENT_NAME}-${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}
${FIND_SFML_COMPONENT_NAME}-${SFML_VERSION_MAJOR}${SFML_VERSION_MINOR}
${FIND_SFML_COMPONENT_NAME}${SFML_VERSION_MAJOR}
${FIND_SFML_COMPONENT_NAME}${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}
${FIND_SFML_COMPONENT_NAME}${SFML_VERSION_MAJOR}${SFML_VERSION_MINOR}
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_LIB_PATHS})
Now
cmake finds everything for me properly. Please update the SFML sources with this. And...
Hope this helps.