SFML community forums

Bindings - other languages => C => Topic started by: Kiatro on June 12, 2016, 01:07:40 pm

Title: Why can't CMAKE find my SFML libraries in CLion?
Post by: Kiatro on June 12, 2016, 01:07:40 pm
Hey, I'm trying to use CLion with SFML, which means I have to use CMake. This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.6)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
endif()

project(Polymorphism)

set(SOURCE_FILES main.cpp)
add_executable(Polymorphism ${SOURCE_FILES})

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Modules" ${CMAKE_MODULE_PATH})
find_package(SFML REQUIRED system window graphics network audio)
if(SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(${main.cpp} ${SFML_LIBRARIES})
endif()

 
This is the error I am getting:
Error:Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY SFML_GRAPHICS_LIBRARY SFML_NETWORK_LIBRARY SFML_AUDIO_LIBRARY)

Any help would be appreciated.
Title: AW: Why can't CMAKE find my SFML libraries in CLion?
Post by: eXpl0it3r on June 12, 2016, 03:03:45 pm
What OS? How do you expect CMake to find it?

Set SFML_ROOT to the place where the include and lib directory are located.
Title: Re: Why can't CMAKE find my SFML libraries in CLion?
Post by: Grundkurs on August 07, 2016, 11:38:27 pm
today i had similar issues and got rid of them with setting SFML_ROOT to the directory as eXpl0it3r suggested.
You should use double-backlashes to pass the exact path-adress.
Like:
Quote
set(SFML_ROOT "C:\\Program Files (x86)\\SFML")

at least that did the trick for me in Windows. I dont know if this applies for linux too, because in linux i didnt need to set SFML_ROOT.
Title: AW: Re: Why can't CMAKE find my SFML libraries in CLion?
Post by: eXpl0it3r on August 08, 2016, 12:42:26 am
You should use double-backlashes to pass the exact path-adress.
Like:
Quote
set(SFML_ROOT "C:\\Program Files (x86)\\SFML")

No, just use forward slashes everywhere. Windows does understand them!