SFML community forums

Help => General => Topic started by: Nexus on April 27, 2012, 07:14:24 pm

Title: Best practice to find SFML with CMake
Post by: Nexus on April 27, 2012, 07:14:24 pm
Hi,

I have experienced that many users have problems to setup Thor correctly because the SFML path is not found. The recent modification to not copy FindSFML.cmake in the CMake module folder anymore makes matters even worse – not only because new users don't find SFML at all, but also because existing users are left with an incorrect FindSFML.cmake (defining SFMLDIR instead of SFML_ROOT for example).

What advice would you, Laurent, give for libraries depending on SFML? Should I copy FindSFML.cmake in my repository and expand CMAKE_MODULE_PATH correspondingly? Actually, that would be an easy solution, but I fear that I overlook updates in this file (but you mentioned they shouldn't happen too often).

Furthermore, to copy FindSFML.cmake to SFML_ROOT during the installation seems somehow questionable, because at this point one has already found SFML ;) But I see you can define the other variables like SFML_LIBRARIES etc.

By the way, you should probably mention those short steps to find SFML in another tutorial, like "Using SFML in other libraries with CMake"... One day, if you have time :)
Title: Re: Best practice to find SFML with CMake
Post by: Laurent on April 27, 2012, 07:30:10 pm
Quote
Should I copy FindSFML.cmake in my repository and expand CMAKE_MODULE_PATH correspondingly?
Yes, definitely.

Quote
I fear that I overlook updates in this file (but you mentioned they shouldn't happen too often).
If your current version of FindSFML.cmake is able to find the required version of SFML, it should always work on any system with any version of SFML. If a future modification to FindSFML.cmake (or to the layout/name of SFML files) breaks this, I'll be in big troubles :)
Title: Re: Best practice to find SFML with CMake
Post by: Nexus on April 27, 2012, 07:43:37 pm
Okay, thank you! :)
Title: Re: Best practice to find SFML with CMake
Post by: Tank on April 29, 2012, 04:39:02 pm
Btw, depending on your version control system, I'd go with a submodule. You can then easily use the newest FindSFML.cmake – if you update your submodule, that is. ;)

E.g. if SFML is in ext/SFML/, you'd append ext/SFML/cmake/Modules/ to CMAKE_MODULE_PATH.
Title: Re: Best practice to find SFML with CMake
Post by: Nexus on April 30, 2012, 12:17:16 am
I use git-subtree (https://github.com/apenwarr/git-subtree), but not for SFML. People that use Thor already have SFML. Thus, I currently just copy the FindSFML file ;)
Title: Re: Best practice to find SFML with CMake
Post by: Tank on April 30, 2012, 11:58:21 am
Sure, I just wanted to give a hint on how to easily work-around that problem. :)
Title: Re: Best practice to find SFML with CMake
Post by: StormWingDelta on April 30, 2012, 05:16:59 pm
Lovely, I just got the old setup for SFML working and now have to learn the new one. :(
Title: Re: Best practice to find SFML with CMake
Post by: Tank on May 07, 2012, 02:28:29 am
And everything for free. You're lucky!