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

Author Topic: Finding SFML with CMake  (Read 2118 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Finding SFML with CMake
« on: March 09, 2011, 07:58:14 pm »
Hello, I am using Windows 7. My SFML installation directory has this structure:
Code: [Select]
# C:/Program Files/C++ Libraries/SFML
  # include
    # SFML
  # lib
    # sfml-window.lib
    # sfml-window-d.lib
  # bin
    # sfml-window-2.dll
    # sfml-window-d-2.dll

I have looked at the FindSFML module and written the following small script (CMakeFiles.txt) in order to find out the SFML paths:
Code: [Select]
cmake_minimum_required (VERSION 2.8)
project (Experiment)

set(SFMLDIR "C:/Program Files/C++ Libraries/SFML")

find_package(SFML REQUIRED)
message("Directory = ${SFMLDIR}")
message("Include = ${SFML_INCLUDE_DIR}")
message("Release = ${SFML_WINDOW_LIBRARY}")
message("Debug = ${SFML_WINDOW_LIBRARY_DEBUG}")
message("Libraries = ${SFML_LIBRARIES}")

When I run CMake in the directory of this file, I get the following output:
Code: [Select]
Found SFML: C:/Program Files/C++ Libraries/SFML/include
Directory = C:/Program Files/C++ Libraries/SFML
Include = C:/Program Files/C++ Libraries/SFML/include
Release =
Debug =
Libraries =
Configuring done

Why are the libraries not found? Do I have to initialize variables apart from SFMLDIR?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Finding SFML with CMake
« Reply #1 on: March 09, 2011, 08:44:35 pm »
Try this:
Code: [Select]
find_package(SFML COMPONENTS window REQUIRED)
I guess I should set the components list to "all modules" if none is specified.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Finding SFML with CMake
« Reply #2 on: March 09, 2011, 09:25:53 pm »
Thank you, this works :)

Is there a possibility to see whether a specific SFML component is available? The path seems not to be affected by the actual existence. I have tried SFML_window_FOUND, but as far as I see, you don't declare such a variable in  FindSFML.cmake.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Finding SFML with CMake
« Reply #3 on: March 09, 2011, 09:31:50 pm »
Quote
Is there a possibility to see whether a specific SFML component is available?

What about testing the corresponding library variable? Like SFML_WINDOW_LIBRARY for the window component.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Finding SFML with CMake
« Reply #4 on: March 09, 2011, 09:56:58 pm »
I have tried that before, somehow I was stupid enough to just move the ".lib" files into the parent directory where they were still found :D

So that's okay now. By the way, a very low-priority issue: FindSFML.cmake contains an install rule with
Code: [Select]
PATTERN ".svn" EXCLUDEThe problem is, Windows 7 seems not to allow files/directories anymore that start with "." (or is it just me?). In TortoiseSVN, one can choose to use "_svn" instead, so maybe this is an option (I hope to escape "." correctly):
Code: [Select]
REGEX "\\.svn|_svn" EXCLUDE
Edit: ".svn" seems to be still allowed, however one cannot manually create such folders. However I remember having had problems with TurtoiseSVN because of this... But nevermind, it's probably not worth a change :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Finding SFML with CMake
« Reply #5 on: March 09, 2011, 10:11:37 pm »
You're right, I'll fix this ;)
Laurent Gomila - SFML developer