SFML community forums

Help => General => Topic started by: Cirrus Minor on June 18, 2014, 09:25:47 am

Title: CMake for your SFML's project
Post by: Cirrus Minor 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  :-[)
Title: Re: CMake for your SFML's project
Post by: Laurent 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.
Title: Re: CMake for your SFML's project
Post by: Cirrus Minor 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
Title: Re: CMake for your SFML's project
Post by: Laurent 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})
Title: Re: CMake for your SFML's project
Post by: Cirrus Minor 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.