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

Author Topic: CMake FindSFML Guide  (Read 2111 times)

0 Members and 1 Guest are viewing this topic.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
CMake FindSFML Guide
« on: March 18, 2011, 12:16:03 am »
Can someone explain to me how to use FindSFML? I can't find any information on it. Specifically, how do I choose between locating the Debug modules and Release modules?
I use the latest build of SFML2

danman

  • Hero Member
  • *****
  • Posts: 1121
    • View Profile
    • Email
CMake FindSFML Guide
« Reply #1 on: March 18, 2011, 07:26:33 am »
Code: [Select]

FIND_PACKAGE (
    SFML
    REQUIRED system window graphics # audio network if you want
)

INCLUDE_DIRECTORIES ( ${SFML_INCLUDE_DIR} )

...
TARGET_LINK_LIBRARIES (
   myexe
# like
   ${SFML_GRAPHICS_LIBRARY}
   ${SFML_WINDOW_LIBRARY}
# or like
   ${SFML_SYSTEM_LIBRARY_DEBUG}


Edit the findSFML.cmake file ;) Laurent explains it at the beginning .
Pointilleur professionnel

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
CMake FindSFML Guide
« Reply #2 on: March 18, 2011, 07:54:37 am »
Slightly improved/fixed example:
Code: [Select]
FIND_PACKAGE (
    SFML
    COMPONENTS system window graphics # audio network if you want
    REQUIRED
)

INCLUDE_DIRECTORIES ( ${SFML_INCLUDE_DIR} )

...
TARGET_LINK_LIBRARIES (
   myexe
   optimized
   ${SFML_GRAPHICS_LIBRARY}
   ${SFML_WINDOW_LIBRARY}
   ${SFML_SYSTEM_LIBRARY}
   debug
   ${SFML_GRAPHICS_LIBRARY_DEBUG}
   ${SFML_WINDOW_LIBRARY_DEBUG}
   ${SFML_SYSTEM_LIBRARY_DEBUG}
)

Options are explained at the beginning of the file (it's always like this with FindXxx.cmake files).
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
CMake FindSFML Guide
« Reply #3 on: March 18, 2011, 08:20:48 am »
Quote from: "Laurent"
Slightly improved/fixed example:
Code: [Select]
FIND_PACKAGE (
    SFML
    COMPONENTS system window graphics # audio network if you want
    REQUIRED
)

INCLUDE_DIRECTORIES ( ${SFML_INCLUDE_DIR} )

...
TARGET_LINK_LIBRARIES (
   myexe
   optimized
   ${SFML_GRAPHICS_LIBRARY}
   ${SFML_WINDOW_LIBRARY}
   ${SFML_SYSTEM_LIBRARY}
   debug
   ${SFML_GRAPHICS_LIBRARY_DEBUG}
   ${SFML_WINDOW_LIBRARY_DEBUG}
   ${SFML_SYSTEM_LIBRARY_DEBUG}
)

Options are explained at the beginning of the file (it's always like this with FindXxx.cmake files).
This is perfect! Thank you!
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
CMake FindSFML Guide
« Reply #4 on: March 18, 2011, 08:48:58 am »
And if you want to force SFML 2:
Code: [Select]
FIND_PACKAGE (
    SFML 2
    ...
Laurent Gomila - SFML developer