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

Author Topic: FindSFML.cmake users, help test the new SFMLConfig.cmake  (Read 2612 times)

0 Members and 1 Guest are viewing this topic.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
FindSFML.cmake users, help test the new SFMLConfig.cmake
« on: February 10, 2018, 03:06:55 pm »
Hello :)

This topic is for users that already use the FindSFML.cmake script provided by SFML, or users that don't yet but would like to and whose project is also based on CMake.

What we would need from you

Since around 1 week ago the PR for supporting find_package(SFML) with a config file is ready for testing but we're still missing feedbacks at the moment. So if you can help on testing this means the pull request can be merged earlier. In particular, we'd appreciate if you tried it with your current workflow to know if any use case is missing. If everything goes well FindSFML.cmake will be removed from future releases.

What does SFMLConfig improve for me?

In terms of use, the SFMLConfig means:
- you don't need to embed FindSFML.cmake in your project anymore, everything is stored in the SFML installation directory
- you're not dealing with variables like SFML_LIBRARIES or SFML_DEPENDENCIES anymore, you just link your library or executable with sfml-${component} where ${component} is one of system, network, audio, window, graphics
- you don't need to use SFML_INCLUDE_DIR anymore to include SFML headers, it is done automatically
- when linking static SFML libraries, you don't need to use SFML_DEPENDENCIES anymore, it is done automatically
- again with static SFML libraries, you don't need to explicitly build with SFML_STATIC, it's done automatically
- you don't need to care about dependencies between SFML modules, for example if you link against sfml-graphics, sfml-system and sfml-window get automatically linked too
- like with FindSFML.cmake, you still don't need to care about whether you're building in Debug or Release mode, the appropriate SFML library is used automatically

How do I test this?

You need to clone the branch, build SFML and install it (build install target).

You should rebuild and install for all the configurations that you want to use (debug/release, dynamic/static/frameworks) to the same target installation directory. Then remove FindSFML.cmake from your project to make sure it's not used, and clear your CMake cache.

After that in terms of use it's just something like
find_package(SFML 2.4 COMPONENTS system window graphics REQUIRED)
target_link_libraries(my_exe PRIVATE sfml-graphics)
in your own CMake code.

Detailed doc for SFMLConfig

(click to show/hide)

Thanks!
Ceylo
Want to play movies in your SFML application? Check out sfeMovie!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32452
    • View Profile
    • SFML's website
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #1 on: February 10, 2018, 06:21:35 pm »
Your examples imply that find_package must contain the full list of SFML components, not just the final ones (ie. sfml-graphics sfml-window sfml-system instead of just sfml-graphics); whereas in target_link_libraries you can just give the final modules and all the dependant ones will automatically be linked. Is that the case?
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #2 on: February 10, 2018, 06:27:34 pm »
Your examples imply that find_package must contain the full list of SFML components, not just the final ones (ie. sfml-graphics sfml-window sfml-system instead of just sfml-graphics); whereas in target_link_libraries you can just give the final modules and all the dependant ones will automatically be linked. Is that the case?
Indeed. Do you find this disturbing?
Want to play movies in your SFML application? Check out sfeMovie!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9676
    • View Profile
    • development blog
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #3 on: February 10, 2018, 07:13:26 pm »
What if the graphics module isn't installed? What's the point of having to specify it when you always have to mention them all anyways?
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32452
    • View Profile
    • SFML's website
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #4 on: February 10, 2018, 07:18:23 pm »
Quote
Indeed. Do you find this disturbing?
I can live with it if there's no way around it. But if we can make it consistent (ie. find_package(X Y) and target_link_libraries(X Y)) then I guess we should do it.

Quote
What if the graphics module isn't installed? What's the point of having to specify it when you always have to mention them all anyways?
It's not "all", it's what you want + their dependencies.
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #5 on: February 10, 2018, 11:08:57 pm »
What if the graphics module isn't installed?
Then it'll be reported as not found (if specified in components of the find_package() call)

What's the point of having to specify it when you always have to mention them all anyways?
I didn't understand what you mean here.

I can live with it if there's no way around it. But if we can make it consistent (ie. find_package(X Y) and target_link_libraries(X Y)) then I guess we should do it.
It's most likely possible to deduce that if the user asked for "graphics" component then we should also consider "window" and "system" to be among the requested components. Will fix that.
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #6 on: February 11, 2018, 02:12:18 pm »
It's most likely possible to deduce that if the user asked for "graphics" component then we should also consider "window" and "system" to be among the requested components. Will fix that.
Done. So now we can do
Code: [Select]
find_package(SFML COMPONENTS graphics REQUIRED)
target_link_libraries(my_exe PRIVATE sfml-graphics)
and have everything linked as needed.

This still means that the user will have to copy more DLLs next to his executable than what he actually specified in target_link_libraries() call. But I guess this is ok.
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #7 on: February 16, 2018, 08:05:09 pm »
Hello,
We still need people to test! Please help if you can.

Thanks,
Ceylo
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #8 on: March 04, 2018, 05:35:45 pm »
I've tested the changes on mac, but others are welcome to try it on their end as well. ;-)
SFML / OS X developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: FindSFML.cmake users, help test the new SFMLConfig.cmake
« Reply #9 on: March 13, 2018, 08:59:22 pm »
Up!
Testing is done on Linux and macOS but we're still missing someone for Windows. If anyone could help unlock this PR… :)
Want to play movies in your SFML application? Check out sfeMovie!