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

Author Topic: Building CSFML 2.0 on Windows  (Read 7354 times)

0 Members and 1 Guest are viewing this topic.

nonexistent

  • Newbie
  • *
  • Posts: 14
    • View Profile
Building CSFML 2.0 on Windows
« on: November 04, 2012, 02:35:22 pm »
Nevermind, see: Laurent's post below
(The instructions below are for the latest SFML and CSFML source from github as of the time of writing)

Figuring out how to get CSFML 2.0 to build on Windows took me a while so to save others some time here's what you need to:

After building SFML 2.0 copy cmake/Modules/FindSFML.cmake into the CSFML directory cmake/Modules (you'll need to mkdir Modules).

Open up src/SFML/CMakeLists.txt from the CSFML directory and find the line:
find_package(SFML 2.0 COMPONENTS system window network graphics audio REQUIRED)

Above this line add the following:
set(SFML_ROOT "C:/Program Files (x86)/SFML")
set(SFML_SYSTEM_LIBRARY_RELEASE "${SFML_ROOT}/lib/sfml-system.lib")
set(SFML_WINDOW_LIBRARY_RELEASE "${SFML_ROOT}/lib/sfml-window.lib")
set(SFML_NETWORK_LIBRARY_RELEASE "${SFML_ROOT}/lib/sfml-network.lib")
set(SFML_GRAPHICS_LIBRARY_RELEASE "${SFML_ROOT}/lib/sfml-graphics.lib")
set(SFML_AUDIO_LIBRARY_RELEASE "${SFML_ROOT}/lib/sfml-audio.lib")
set(SFML_SYSTEM_LIBRARY_DEBUG "${SFML_ROOT}/lib/sfml-system-d.lib")
set(SFML_WINDOW_LIBRARY_DEBUG "${SFML_ROOT}/lib/sfml-window-d.lib")
set(SFML_NETWORK_LIBRARY_DEBUG "${SFML_ROOT}/lib/sfml-network-d.lib")
set(SFML_GRAPHICS_LIBRARY_DEBUG "${SFML_ROOT}/lib/sfml-graphics-d.lib")
set(SFML_AUDIO_LIBRARY_DEBUG "${SFML_ROOT}/lib/sfml-audio-d.lib")

(SFML_ROOT should be set to wherever you installed SFML 2.0)

And now cmake should be happy and you can build CSFML, etc.
« Last Edit: November 06, 2012, 11:34:50 pm by nonexistent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Building CSFML 2.0 on Windows
« Reply #1 on: November 04, 2012, 04:57:52 pm »
Quote
Above this line add the following:
set(SFML_ROOT "C:/Program Files (x86)/SFML")
set(SFML_SYSTEM_LIBRARY_RELEASE "${SFML_ROOT}/lib/sfml-system.lib")
[...]
No! This is exactly what the find_package function does, it finds everything for you automatically.

If something needed to be added to the CSFML build files, it would already been done don't you think? ;)
They work out of the box, if you need to change something then you're wrong.
Laurent Gomila - SFML developer

nonexistent

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Building CSFML 2.0 on Windows
« Reply #2 on: November 05, 2012, 08:37:27 am »
Quote
Above this line add the following:
set(SFML_ROOT "C:/Program Files (x86)/SFML")
set(SFML_SYSTEM_LIBRARY_RELEASE "${SFML_ROOT}/lib/sfml-system.lib")
[...]
No! This is exactly what the find_package function does, it finds everything for you automatically.

If something needed to be added to the CSFML build files, it would already been done don't you think? ;)
They work out of the box, if you need to change something then you're wrong.

It works perfectly without modification on Linux but I had to do this for Windows.  I certainly don't know CMake particularly well so it's entirely possible I'm doing something wrong.  For what it's worth though, my system is running 64-bit Win 7, Cmake 2.8.10, and nmake from VS 11.  I also tried CMake 2.8.9, 2.8.8, 2.8.7 with the same results.

In another thread someone mentioned that the install script for SFML used to copy FindSFML.cmake into the CMake share/Modules directory, but it was changed to no longer do this.  I'm assuming the CSFML is supposed to see this from from the SFML install directory w/ SFML_ROOT?

On that note, did I miss a configuration step setting SFML_ROOT?  The CSFML CMake couldn't find its value until I explicitly set it on my machine.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Building CSFML 2.0 on Windows
« Reply #3 on: November 05, 2012, 08:56:01 am »
SFML_ROOT is the only thing that you should define, if SFML is not installed in a standard path (which is often the case on Windows, rarely on Linux). It should be defined when you configure the project ("Add entry" button if you use cmake-gui, or "-DSFML_ROOT=..." if you call cmake from the command line), not hardcoded into CMake files -- because it will be different for every user. Note that you can also define it as an environment variable, if you don't want to do it everytime you create a new project.

And yes, FindSFML.cmake must either be copied to the Modules directory of your CMake install (once its done, you can find SFML in any CMake project), or define the CMAKE_MODULE_DIRECTORY (not sure about the name) variable to the path that contains it.
Laurent Gomila - SFML developer

nonexistent

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Building CSFML 2.0 on Windows
« Reply #4 on: November 06, 2012, 11:35:32 pm »
Thanks for the clarification, I've edited my original post