SFML community forums

Help => General => Topic started by: texus on April 08, 2018, 09:08:29 am

Title: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
Post by: texus 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)

Title: Re: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
Post by: Ceylo 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.
Title: Re: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
Post by: texus 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.
Title: Re: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
Post by: Ceylo 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.
Title: Re: [iOS] SFMLConfigDependencies.cmake looks for OpenGL
Post by: Jonny on April 13, 2018, 02:35:35 am
There's a PR which should address this now: https://github.com/SFML/SFML/pull/1416