Hello,
I'm new to the forum (and using forums in general), so be gentle, please.
And nice to meet you!
I've just started using SFML today. What I want to do is to compile SFML, along my game, within CMake project.
I think, I've correctly compiled and linked SFML, because below code works as expected:
sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)
Before I begin to describe the issue, I'll just say that I've tried to search for an answer, but to no avail. I've found this
https://en.sfml-dev.org/forums/index.php?topic=21110.0, but I haven't found my answer there. I've also read CMake Tutorial for compiling SFML, but it doesn't work for me, as I don't want to compile just SFML, but whole project (and SFML is a part of it). SFML I use is taken directly from github (at tag
2.5.0) and added to my project as git submodule.
My problem is that I get a warning while compiling AudioDevice.cpp:
../deps/sfml/src/SFML/Audio/AudioDevice.cpp:110:10: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
std::auto_ptr<AudioDevice> device;
From the knowledge I've gathered so far, it seems the issue is with my project using different compiler than compiler used to compile SFML. However, I don't think that's possible, as my project compiles SFML (so the compiler should be the same).
Below are my CMake files, but only those that I think matter. I also removed lines which include different libraries etc.
My sfml.cmake:
set(SFML_DIR "deps/sfml/"
CACHE PATH "The path to the SFML framework.")
add_subdirectory(${SFML_DIR} ${CMAKE_BINARY_DIR}/sfml)
include_directories(SYSTEM ${SFML_DIR}/sfml/include
${SFML_DIR}/sfml/include)
My main CMakeLists.txt:
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project("Snake With A Twist")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
include(sfml)
add_subdirectory(app)
My app CMakeLists.txt:
add_executable(SnakeWithATwist main.cpp)
target_link_libraries(SnakeWithATwist
PRIVATE sfml-window
)
target_compile_options(SnakeWithATwist PRIVATE -Wall -Wextra -Werror)
target_compile_features(SnakeWithATwist PRIVATE cxx_std_14)
If you want a deeper look, here is my project:
https://github.com/JinLisek/SimpleSnakeGameThe correction is probably easy, but since my CMake experience is not that big, I just can't wrap my head around it. Any help is welcome and I'll be very grateful for all answers!