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

Author Topic: CMake for your SFML's project  (Read 2088 times)

0 Members and 1 Guest are viewing this topic.

Cirrus Minor

  • Full Member
  • ***
  • Posts: 121
    • View Profile
CMake for your SFML's project
« on: June 18, 2014, 09:25:47 am »
Hi !
Here is the complete CMake config file for my project.
I use it on Windows and OSX.
Code: [Select]
cmake_minimum_required(VERSION 2.6)

# Projet name
project("Witch_Blast")

file(
        GLOB_RECURSE
        source_files
        src/*
)

add_executable(
        "Witch_Blast"
        ${source_files}
)

# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2.1 REQUIRED system window graphics audio)
target_link_libraries(Witch_Blast ${SFML_LIBRARIES})

include_directories(${SFML_INCLUDE_DIR})

I've just had feedback from a Linux user: he told me I have to add the GLEW library to CMake.

How are you dealing with GLEW in your project's Cmake files ? Should I "condition" it to OS ?
(Sorry, I'm really nor skilled with CMake  :-[)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: CMake for your SFML's project
« Reply #1 on: June 18, 2014, 10:55:14 am »
Nop, you shouldn't have to link SFML dependencies yourself, unless you're using SFML > 2.1 and static libraries.
Laurent Gomila - SFML developer

Cirrus Minor

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: CMake for your SFML's project
« Reply #2 on: June 18, 2014, 11:26:59 am »
The user told me he had to grab the latest SFML code (so yes, he's using > 2.1) because of its GLEW version:

http://www.developpez.net/forums/d1429467-4/applications/developpement-2d-3d-jeux/projets/witch-blast-dungeon-crawl-shooter/#post7862835

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: CMake for your SFML's project
« Reply #3 on: June 18, 2014, 11:35:44 am »
But he didn't compile SFML statically, did he?

Anyway, you can try to link your executable to ${SFML_DEPENDENCIES} and see what happens.

target_link_libraries(Witch_Blast ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
Laurent Gomila - SFML developer

Cirrus Minor

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: CMake for your SFML's project
« Reply #4 on: June 20, 2014, 08:15:07 am »
Thanks Laurent, but I don't think I have to change anything.

The user told me his only problem was his GLEW version, or something like that, but it's OK.