Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Best practice to find SFML with CMake  (Read 3295 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Best practice to find SFML with CMake
« 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 :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Best practice to find SFML with CMake
« Reply #1 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 :)
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Best practice to find SFML with CMake
« Reply #2 on: April 27, 2012, 07:43:37 pm »
Okay, thank you! :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Best practice to find SFML with CMake
« Reply #3 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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Best practice to find SFML with CMake
« Reply #4 on: April 30, 2012, 12:17:16 am »
I use git-subtree, but not for SFML. People that use Thor already have SFML. Thus, I currently just copy the FindSFML file ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Best practice to find SFML with CMake
« Reply #5 on: April 30, 2012, 11:58:21 am »
Sure, I just wanted to give a hint on how to easily work-around that problem. :)

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: Best practice to find SFML with CMake
« Reply #6 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. :(
I have many ideas but need the help of others to find way to make use of them.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Best practice to find SFML with CMake
« Reply #7 on: May 07, 2012, 02:28:29 am »
And everything for free. You're lucky!

 

anything