mercredi 21 novembre 2018

"Could NOT find SFML" error in CLion/CMake on Windows 10?

I'm currently trying to integrate SFML into CLion on Windows 10 (I'm not very familiar with SFML or CMake). I've tried a few different things and combinations in my CMakeLists.txt, but I keep getting the same error:

CMake Error at cmake_modules/FindSFML.cmake:199 (message):              
  Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY
  SFML_GRAPHICS_LIBRARY SFML_NETWORK_LIBRARY SFML_AUDIO_LIBRARY)
Call Stack (most recent call first):
  CMakeLists.txt:12 (find_package)

This is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)
project(P3)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

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

set(SFML_ROOT "C:/SFML-2.5.1")

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
find_package(SFML REQUIRED system window graphics network audio)
if(SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    link_directories("C:/SFML-2.5.1")
    target_link_libraries(P3 ${SFML_LIBRARIES})
endif()

I'm not really sure what I'm doing wrong here. I've been at it for a fairly long while and despite countless Google searches and research, I can't seem to find a solution. Any help would be greatly appreciated and thank you in advance.

Also, my FindSFML.cmake file is located in a cmake_modules folder that I created within my project folder that is within my CLionProjects folder if that's useful information.

Aucun commentaire:

Enregistrer un commentaire