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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Masalan

Pages: [1]
1
General / CMake include problem
« on: June 10, 2021, 09:06:35 pm »
Hello. Working on Windows. Im trying to dive in gamedev, but this thing is blocking me.
Im trying to include "SFML/Graphics.hpp" in one of my header files, located in src folder. Main.cpp is located in the same directory.
#pragma once

#include <SFML/Graphics.hpp>

class Window
{
public:
    Window(const std::string& window_name);

    void update();

    void beginDraw();
    void Draw(const sf::Drawable& drawable);
    void endDraw();

    bool isOpen() const;

private:
    sf::RenderWindow window;
}
 
This is the trouble header. When compiling it says that it cant find SFML/Graphics.

CMakeLists.txt, located out of src folder.
cmake_minimum_required(VERSION 3.20.3)

project(SNAKE)

add_subdirectory(src)


set(SFML_DIR "c:\\SFML\\lib\\cmake\\SFML\\")
find_package(SFML 2.5 COMPONENTS graphics audio REQUIRED)
target_link_libraries(${PROJECT_NAME} sfml-graphics sfml-audio)
 

window.hpp is located in src folder. CMakeLists.txt in src folder:
add_executable(${PROJECT_NAME} main.cpp)


add_library(window window.cpp window.hpp)


set(LIBRARIES window)
target_link_libraries(${PROJECT_NAME} ${LIBRARIES})
 

Error log:
In file included from E:\GameDev\SFML\Snake\src\window.cpp:1:
E:\GameDev\SFML\Snake\src\window.hpp:3:10: fatal error: SFML/Graphics.hpp: No such file or directory
 #include <SFML/Graphics.hpp>
 

Whats interesting, main.cpp located in the same directory has no trouble including "SFML/Graphics".
Im new to cmake and dont know how things work. Can someone help me to make "window.hpp" include "SFML/Graphics.hpp" correctly?

Pages: [1]