Hello, I tried everything to set it up, but it didn't help. I use MinGW 32-bit (I ve downloaded it from link on sfml download page) and SFML for MinGW 32-bit. Here are my CMake and code (default).
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
cmake_minimum_required(VERSION 3.14)
set(PROJECT_NAME MyGame)
project(${PROJECT_NAME})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -static")
set(CMAKE_CXX_STANDARD 17)
set(SOURCE_FILES main.cpp)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_executable(${PROJECT_NAME} WIN32 ${SOURCE_FILES})
else ()
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
endif ()
set(SFML_ROOT "${CMAKE_SOURCE_DIR}/SFML-2.5.1")
set(SFML_DIR "${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/cmake/SFML")
#set(SFML_STATIC_LIBRARIES TRUE)
set(CMAKE_MODULE_PATH "${SFML_ROOT}/lib/cmake/SFML")
find_package(SFML 2 REQUIRED COMPONENTS audio graphics window system)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
link_directories(${SFML_LINK_DIR})
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
else ()
message("SFML NOT FOUND")
endif()
I've tried everything; I need SFML libs folder in my project folder.
====================[ Build | MyGame | Release ]================================
"C:\Program Files\JetBrains\CLion\bin\cmake\win\bin\cmake.exe" --build "D:\JetBrains Projects\CLion Projects\MyGame\cmake-build-release" --target MyGame -- -j 4
-- Found SFML 2.5.1 in D:/JetBrains Projects/CLion Projects/MyGame/SFML-2.5.1/lib/cmake/SFML
-- Configuring done
-- Generating done
-- Build files have been written to: D:/JetBrains Projects/CLion Projects/MyGame/cmake-build-release
[ 50%] Building CXX object CMakeFiles/MyGame.dir/main.cpp.obj
D:\JetBrains Projects\CLion Projects\MyGame\main.cpp:1:10: fatal error: SFML/Graphics.hpp: No such file or directory
#include <SFML/Graphics.hpp>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
mingw32-make.exe[3]: *** [CMakeFiles\MyGame.dir\build.make:62: CMakeFiles/MyGame.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:72: CMakeFiles/MyGame.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:84: CMakeFiles/MyGame.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: MyGame] Error 2