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

Author Topic: [iOS] SFMLConfigDependencies.cmake looks for OpenGL  (Read 4837 times)

0 Members and 1 Guest are viewing this topic.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
[iOS] SFMLConfigDependencies.cmake looks for OpenGL
« on: April 08, 2018, 09:08:29 am »
When using the latest SFML version from github, I can't use SFMLConfig.cmake to find SFML when building for iOS.
On iOS the sfml-window target has to link to OpenGL ES but the SFMLConfigDependencies.cmake always looks for OpenGL, so CMake gives the following error on find_package(SFML ...)
CMake Error at /Users/texus/Desktop/SFML/build-iOS/SFMLConfigDependencies.cmake:34 (set_property):
  set_property could not find TARGET OpenGL.  Perhaps it has not yet been
  created.
Call Stack (most recent call first):
  /Users/texus/Desktop/SFML/build-iOS/SFMLConfigDependencies.cmake:55 (sfml_bind_dependency)
  /Users/texus/Desktop/SFML/build-iOS/SFMLConfig.cmake:117 (include)
  /Users/texus/Desktop/SFML/cmake/toolchains/iOS.toolchain.cmake:211 (find_package)
  CMakeLists.txt:175 (find_host_package)

TGUI: C++ SFML GUI

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
« Reply #1 on: April 08, 2018, 11:05:51 am »
Hello texus,

SFMLConfig.cmake indeed doesn't support iOS for now (like previous FindSFML.cmake). Feel free to open a PR if you want to add this support.
Want to play movies in your SFML application? Check out sfeMovie!

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
« Reply #2 on: April 11, 2018, 08:17:30 pm »
I never noticed that the FindSFML.cmake didn't support iOS. It always found SFML fine when building my library (I just had to manually set the dependencies as it found the macOS ones by default if they were installed). But it turns out that it also complains about not being able to link against OpenGL when building a final executable (which I didn't test earlier). So the change to SFMLConfig.cmake just made the failure happen at an earlier point and thus makes the error more visible.

I had a look at fixing SFMLConfig.cmake myself but I can't figure out how I can get cmake to find the right dependencies in the right places.

Fixing it in FindSFML.cmake was easier. I'm already shipping a slightly modified version of FindSFML.cmake with my library (the goal was to make it obsolete now SFMLConfig.cmake exists), so I just fixed that FindSFML.cmake file to link to the right libs on iOS.
TGUI: C++ SFML GUI

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
« Reply #3 on: April 11, 2018, 09:23:49 pm »
Indeed, the fact that you had to manually set the dependencies clearly shows that it wasn't supported.

To give some insight, the SFML config file is generated automatically according to targets to be exported. For desktop platforms the call to sfml_find_package(OpenGL ...) in src/SFML/Window/CMakeLists.txt creates this OpenGL target and flags it to be exported. But in iOS case sfml_find_package(OpenGL ...) is not called. Thus no OpenGL target gets exported. Thus you get an CMake error telling that the OpenGL target doesn't exist. There are probably quite a few changes to bring to current CMake code because there is no need to search for any OpenGL package on iOS, as usually you directly link using "-framework OpenGLES".


Those changes will probably arrive soon as they are also needed to get all GUI examples running on iOS.
Want to play movies in your SFML application? Check out sfeMovie!

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
« Reply #4 on: April 13, 2018, 02:35:35 am »
There's a PR which should address this now: https://github.com/SFML/SFML/pull/1416