Friday, March 4, 2016

CLion + SFML (+ MSYS2)



SFML 2.3.2 (GCC 4.9.2 MinGW (DW2) - 32-bit)

///////////////////////////////////////////////////////
///if with MSYS22
/////////////////////////////////////////////////////// 
Install MSYS2.
it’s installed in C:\msys64 on 64-bit systems 
 
C:\> SET LIBRARY_PATH=C:\msys64\mingw64\lib
C:\> SET PATH=%PATH%;C:\msys64\mingw64\bin 
C:\> SET INCLUDE=C:\msys64\mingw64\include  
 
pacman -S mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-sfml


main.cpp (test)
#include <SFML/Graphics.hpp> 
 
int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Application"); 
    sf::CircleShape shape; 
    shape.setRadius(40.f); 
    shape.setPosition(100.f, 100.f); 
    shape.setFillColor(sf::Color::Cyan); 
    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(); 
    }
}


CMakeLists.txt

cmake_minimum_required(VERSION 3.14)
project(untitled10)

set(CMAKE_CXX_STANDARD 11)

set(EXECUTABLE_NAME "untitled10")
add_executable(${EXECUTABLE_NAME} main.cpp)

find_package(SFML 2 COMPONENTS system window graphics network audio)

target_link_libraries(${EXECUTABLE_NAME}         
libsfml-audio 
libsfml-graphics 
libsfml-network 
libsfml-system 
libsfml-window