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.


Messages - rednik

Pages: [1]
1
General / Sfml v3 with cmake
« on: May 07, 2022, 01:00:12 pm »
So im trying to include latest sfml snapshot in clion, but it doesnt work

Normally, with sfml v2.5.1 (which works), my CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 3.22)
project(sfml)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")

set(SFML_STATIC_LIBRARIES TRUE)
set(SFML_DIR "SFML-2.5.1/lib/cmake/SFML")


find_package(SFML COMPONENTS graphics audio REQUIRED)

add_executable(sfml main.cpp)

target_link_libraries(sfml sfml-graphics sfml-audio)
 

But with latest sfml and CMakeLists.txt looking like this
cmake_minimum_required(VERSION 3.22)
project(sus)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")

set(SFML_STATIC_LIBRARIES TRUE)
set(SFML_DIR "sfml/lib/cmake/SFML")


find_package(SFML COMPONENTS Graphics Audio REQUIRED)

add_executable(sus main.cpp)

target_link_libraries(sus sfml-graphics sfml-audio)
 
when compiling it just gives me an error
FAILED: CMakeFiles/sus.dir/main.cpp.obj
C:\PROGRA~1\JETBRA~1\CLION2~1.1\bin\mingw\bin\G__~1.EXE   -g -std=gnu++20 -MD -MT CMakeFiles/sus.dir/main.cpp.obj -MF CMakeFiles\sus.dir\main.cpp.obj.d -o CMakeFiles/sus.dir/main.cpp.obj -c C:/Users/rednik/CLionProjects/sus/main.cpp
C:/Users/rednik/CLionProjects/sus/main.cpp:1:10: fatal error: SFML/Graphics.hpp: No such file or directory
    1 | #include <SFML/Graphics.hpp>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
 

If Graphics and Audio are written in lowercase then cmake gives an error:
CMake Error at sfml/lib/cmake/SFML/SFMLConfig.cmake:150 (message):
  Found SFML but requested component 'audio' is missing in the config defined
  in sfml/lib/cmake/SFML.
Call Stack (most recent call first):
  CMakeLists.txt:12 (find_package)


CMake Error at CMakeLists.txt:12 (find_package):
  Found package configuration file:

    C:/Users/rednik/CLionProjects/sus/sfml/lib/cmake/SFML/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.
 

Thanks in advance

Pages: [1]