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

Author Topic: CMake and Visual Studio 2010  (Read 5273 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
CMake and Visual Studio 2010
« on: November 16, 2010, 09:31:28 pm »
Hello, I'm using Visual Studio 2010 and I've got problems to setup SFML with CMake. I followed the tutorial, performed the configure and generate steps and tried to compile the SFML libraries inside a MSVC++ solution. However, errors of the form
Quote
LINK : fatal error LNK1181: Input file "C:/Program" cannot be opened.
(translated) appeared. The reason is, the full paths specified in Project Properties -> Librarian -> Command Line -> Additional Options are subdirectories of C:/Program files/, and the space inside the string "Program files" is interpreted as argument-separator. A solution would be to write the whole argument inside "" quotation marks. Is there a possibility to adapt the CMake configuration correspondingly? I have already changed the variable GLEW_LIBRARY in CMake, but how about the other libraries?

And another question: Can I specify in CMake the directory where the libraries (.lib or .dll files) should be generated? It would be nice if I didn't have to change the paths inside the generated MSVC++ solution every time.

Thanks in advance!
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
CMake and Visual Studio 2010
« Reply #1 on: November 16, 2010, 09:46:39 pm »
Never use paths with spaces. Ever. That will be much simpler than finding workarounds for tools that don't care about the problems it may cause.

However, my CMake setup is supposed to be aware of that. Which path is it? Which linker option? Which configuration (static or dynamic)?

Quote
And another question: Can I specify in CMake the directory where the libraries (.lib or .dll files) should be generated? It would be nice if I didn't have to change the paths inside the generated MSVC++ solution every time.

You can choose where to install SFML with CMAKE_INSTALL_PREFIX, and that's really what you should do instead of trying to control where the libraries are generated (which is supposed to be a temporary path).
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
CMake and Visual Studio 2010
« Reply #2 on: November 17, 2010, 10:07:29 am »
Quote from: "Laurent"
Never use paths with spaces. Ever. That will be much simpler than finding workarounds for tools that don't care about the problems it may cause.
In my opinion, it's a little pity that there are still tools which can't handle spaces properly. I mean, since spaces in paths are neither a new fashion nor something especially exotic, at least under Windows.

Quote from: "Laurent"
However, my CMake setup is supposed to be aware of that.
Hm, did you (or somebody else) test space-containing paths with VS 2010? Do they work?

Quote from: "Laurent"
Which path is it? Which linker option? Which configuration (static or dynamic)?
C:/Program files/C++ Libraries/SFML; Debug static (no shared libs).

Quote from: "Laurent"
You can choose where to install SFML with CMAKE_INSTALL_PREFIX, and that's really what you should do instead of trying to control where the libraries are generated (which is supposed to be a temporary path).
Okay, I'll try that as soon as I succeed to compile SFML. ;)
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
CMake and Visual Studio 2010
« Reply #3 on: November 17, 2010, 10:31:14 am »
Actually, with VS 2010 the problem was the opposite: before I added """ symbols manually around paths, but it seems that the CMake generator for 2010 already handles that (unlike for 2008 or 2005).

So it's supposed to work.

See this topic:
http://www.sfml-dev.org/forum/viewtopic.php?t=3519
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
CMake and Visual Studio 2010
« Reply #4 on: November 18, 2010, 11:48:44 am »
Quote from: "Laurent"
So it's supposed to work.
Without further configurations on my side? Unfortunately, I can't confirm that.

I don't know whether it's even SFML's fault. I think CMake should be able to specify the paths inside VS 10 correctly. I'm using CMake 2.8.3, by the way (I recently updated it).
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
CMake and Visual Studio 2010
« Reply #5 on: November 18, 2010, 12:03:27 pm »
You said the guilty path is "C:/Program files/C++ Libraries/SFML", but where is it used in your linker options?
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
CMake and Visual Studio 2010
« Reply #6 on: November 18, 2010, 01:03:18 pm »
The "additional options" textfield in Project options -> Librarian -> Command line contains the following entries.

Project sfml-graphics:
Quote
C:/Program Files/C++ Libraries/SFML/extlibs/libs-msvc/freetype.lib C:/Program Files/C++ Libraries/SFML/extlibs/libs-msvc/glew.lib C:/Program Files/C++ Libraries/SFML/extlibs/libs-msvc/jpeg.lib

Project sfml-audio:
Quote
C:/Program Files/C++ Libraries/SFML/extlibs/libs-msvc/OpenAL32.lib C:/Program Files/C++ Libraries/SFML/extlibs/libs-msvc/sndfile.lib

And here, the spaces of the paths are interpreted as separators. When I add the quotation marks around each path manually, everything works fine.
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
CMake and Visual Studio 2010
« Reply #7 on: November 18, 2010, 01:20:55 pm »
Hmm, I used to add them manually in my CMake files, but according to Mikey in the other topic they were already added by CMake (only for VS 2010), so I removed the code and it worked for him.

You can try to revert to the revision before the corresponding fix and see if it works for you.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
CMake and Visual Studio 2010
« Reply #8 on: November 20, 2010, 02:24:56 am »
In the meantime, I have been experimenting quite a while and trying to understand the CMake configuration files. The old revision (before the change) didn't work at all, so I've taken a look at Macros.cmake and adapted it. I inserted the quotation marks (escaped \") by changing the line 41 from
Code: [Select]
set(LIBRARIES "${LIBRARIES} ${lib}")to
Code: [Select]
set(LIBRARIES "${LIBRARIES} \"${lib}\"")
Linker entries in VS 2010 are now surrounded by "", thus paths containing spaces are recognized correctly. On the other hand, &quot seems to be wrong, at least for Visual Studio 2010. I don't know about older versions.

After several other issues (VS must run with admin rights for INSTALL, I didn't think of SFML_STATIC, I had to do all steps again and again for the smallest change as CMake would have upset otherwise...), I finally managed to compile SFML and code that uses it. :)

However, the INSTALL project doesn't generate sfml-main(-d).lib, is that intended?
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
CMake and Visual Studio 2010
« Reply #9 on: November 20, 2010, 09:14:46 am »
Quote
Linker entries in VS 2010 are now surrounded by "", thus paths containing spaces are recognized correctly. On the other hand, &quot seems to be wrong, at least for Visual Studio 2010. I don't know about older versions.

" is needed for other versions, double quotes don't work because the project file is in XML format. I don't know if it's CMake or VS, but this stuff is so confusing and not consistent at all :evil:

Quote
However, the INSTALL project doesn't generate sfml-main(-d).lib, is that intended?

Nop :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
CMake and Visual Studio 2010
« Reply #10 on: November 20, 2010, 11:30:58 pm »
I applied your fix for double quotes, and sfml-main now has an install rule ;)
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
CMake and Visual Studio 2010
« Reply #11 on: November 21, 2010, 03:47:15 pm »
Cool! :)

Thanks a lot for your support!
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: