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

Author Topic: Absolutely Confused with CMake in finding SFML include files  (Read 4386 times)

0 Members and 1 Guest are viewing this topic.

arnavb

  • Newbie
  • *
  • Posts: 18
    • View Profile
Absolutely Confused with CMake in finding SFML include files
« on: August 12, 2017, 10:23:53 pm »
I was trying to configure CMake to link the SFML libraries on my Windows computer, and am failing miserably.

My directory looks as follows

Code: [Select]
   |-build
      |__//Build stuff
   |-cmake_modules
     |__FindSFML.cmake
   |-main.cpp
   |-CmakeLists.txt

For some reason, while CMake is able to find SFML, it is unable to find the include directory of it. I run CMake as follows:

Code: [Select]
cmake .. -DCMAKE_PREFIX_PATH=C:/SFML-2.4.2

and my CMakeLists.txt looks as follows:

Code: [Select]
cmake_minimum_required(VERSION 3.9)
project(SFML-CmakeTest)

set(CMAKE_BUILD_TYPE Release)

set(EXECUTABLE_NAME "sfml_test_cmake")

add_executable(${EXECUTABLE_NAME} main.cpp)

set(SFML_FIND_PATH ${CMAKE_PREFIX_PATH})
set(SFML_INCLUDE_PATH "${SFML_FIND_PATH}/include")

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2.4 REQUIRED system window graphics network audio)
include_directories(${SFML_INCUDE_PATH})
target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})

my main.cpp is as simple as it gets:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow testWindow{ sf::VideoMode{ 640, 480 }, "Test Window", sf::Style::Default };

while (testWindow.isOpen())
{
sf::Event winEvent;
while (testWindow.pollEvent(winEvent))
{
if (winEvent.type == sf::Event::Closed)
{
testWindow.close();
}
}
testWindow.clear();
testWindow.display();
}
}

Unfortunately, I get the VS error, unable to find SFML/Graphics.hpp. What am I doing wrong? My SFML is located in C:\SFML-2.4.2

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10828
    • View Profile
    • development blog
    • Email
Re: Absolutely Confused with CMake in finding SFML include files
« Reply #1 on: August 13, 2017, 01:36:40 am »
SFML_INCUDE_PATH is certainly misspelled. Other than that, if SFML is not in a standard search directory, you should set SFML_ROOT to the root directory containing the SFML include and lib directories.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

arnavb

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Absolutely Confused with CMake in finding SFML include files
« Reply #2 on: August 13, 2017, 06:55:14 pm »
Ok, thanks for the reply, Ill be sure to try that out.

 

anything