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

Author Topic: FindSFML.cmake broken with mingw?  (Read 2955 times)

0 Members and 1 Guest are viewing this topic.

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
FindSFML.cmake broken with mingw?
« on: August 01, 2013, 01:24:33 am »
Hello!

I am having issues with the FindSFML.cmake and i am not sure if it is me doing something wrong or the file itself not working. I want to link to SFML in my project, on both windows and linux. On linux it works fine, but on windows it fails (using mingw).

In the CMakeLists.txt I use the following to find SFML:

find_package(SFML 2 COMPONENTS window system REQUIRED)

This works fine on linux, but on windows i get the following error:

Could NOT find SFML (missing: SFML_WINDOW_LIBRARY SFML_SYSTEM_LIBRARY)

I built SFML from the source using mingw with the default settings, followed by a "make install" which installed SFML to the default location in programs (x86).

Despite this, i managed to get it to run by calling:
find_package(SFML REQUIRED)
include_directories("${SFML_INCLUDE_DIR}")
link_directories("${SFML_INCLUDE_DIR}/../lib")
...and then linking to the libs manually (i.e. sfml-window sfml-graphics etc)

So even if it works, it seems to me like it isn't the way it should be. Any ideas on something i am doing wrong, or is this actually an issue with the find module?

Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FindSFML.cmake broken with mingw?
« Reply #1 on: August 01, 2013, 07:58:55 am »
Quote
a "make install" which installed SFML to the default location in programs (x86).
"C:\Program Files\SFML" is not a standard path for CMake. You must set the CMake variable SFML_ROOT to this path for FindSFML.cmake to be able to find your SFML installation.
Laurent Gomila - SFML developer

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Re: FindSFML.cmake broken with mingw?
« Reply #2 on: August 01, 2013, 01:27:25 pm »
I see. but how come that it can find SFML using this line then?

find_package(SFML REQUIRED)

That sets SFML_INCLUDE_DIR to the program files folder and i can use it.

EDIT:  Also, why not adding the program files folder to the list of paths in the cmake module file where it will try searching for SFML? This would make sense imo since that is where SFML installs to by defualt on windows, and i don't think that many users choose a different path.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FindSFML.cmake broken with mingw?
« Reply #3 on: August 01, 2013, 01:30:35 pm »
Ah, sorry, I thought SFML wa not found at all. So it finds the include directory but not the libraries? Hmm then maybe C:\Program Files\<lib-name> is a standard path for CMake. And I have no idea why it can't find the libraries.

You can still try with SFML_ROOT, maybe it will make a difference.
Laurent Gomila - SFML developer

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Re: FindSFML.cmake broken with mingw?
« Reply #4 on: August 01, 2013, 03:43:07 pm »
Hmmm yeah that is weird. If i set the SFML_ROOT, it works properly.

But it is still really weird that it still finds the include directory, but not the libraries if i _don't_ set SFML_ROOT.

In my opinion, since it finds the include directory, perhaps the find module could be fixed to find the libraries without setting the SFML_ROOT if it finds the include directory? The benefit of this would be that for standard windows users who uses mingw, they would just have to configure and generate instead of getting an error and finding out how to set the SFML_ROOT and such. And the fix is probably easy. :)

What do you think?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FindSFML.cmake broken with mingw?
« Reply #5 on: August 01, 2013, 04:16:50 pm »
The only explanation is that the find_path CMake command has "Program Files" in its default search paths, whereas the find_library CMake command doesn't. Which would be really strange.

I need to do some tests to clarify this.
Laurent Gomila - SFML developer

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Re: FindSFML.cmake broken with mingw?
« Reply #6 on: August 01, 2013, 05:46:33 pm »
Alright.

Keep in mind that other people i talked to who use SFML on windows installed to the standard path, for them it worked as expected. But they both use MSVC. I myself got this error on two different windows machines, but both are using mingw. Perhaps it has to do with the .a and .dll.a name endings that mingw gives its libraries?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FindSFML.cmake broken with mingw?
« Reply #7 on: August 01, 2013, 07:31:10 pm »
Quote
Perhaps it has to do with the .a and .dll.a name endings that mingw gives its libraries?
The fact that it works with SFML_ROOT defined cancels this kind of explanations.
Laurent Gomila - SFML developer