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

Author Topic: Why can't CMAKE find my SFML libraries in CLion?  (Read 8381 times)

0 Members and 1 Guest are viewing this topic.

Kiatro

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Why can't CMAKE find my SFML libraries in CLion?
« 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.
« Last Edit: June 12, 2016, 01:17:06 pm by Kiatro »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Why can't CMAKE find my SFML libraries in CLion?
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Grundkurs

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Why can't CMAKE find my SFML libraries in CLion?
« Reply #2 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.
« Last Edit: August 07, 2016, 11:41:29 pm by Grundkurs »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Re: Why can't CMAKE find my SFML libraries in CLion?
« Reply #3 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!
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/