SFML community forums

Help => General => Topic started by: ToMadeira on March 15, 2023, 01:44:28 am

Title: SFML + CMake(VS 2022)
Post by: ToMadeira on March 15, 2023, 01:44:28 am
Hello, I am new to C++ and trying to see some Git projects but there is probably some simple problem and I cant get it;

So, there is a project with 2D lights in SFML (https://github.com/MiguelMJ/Candle). Author gave us cmake guide for installing:

mkdir build && cd build
cmake .. -DBUILD_DEMO=ON
cmake --build .


So I git project and create "build" directory in it. To set SFML root directory in CMakeLists.txt I change:

# might need to set manually SFML_ROOT to the install location of SFML for Windows users
# set(SFML_ROOT "")
if(SFML_ROOT STREQUAL "")
   find_package(SFML 2.5 REQUIRED COMPONENTS  graphics)
endif()


To:

# might need to set manually SFML_ROOT to the install location of SFML for Windows users
set(SFML_ROOT "c:/Users/Pudje/source/repos/SFML-2.5.1/")
# if(SFML_ROOT STREQUAL "")
#   find_package(SFML 2.5 REQUIRED COMPONENTS  graphics)
# endif()


Then do a build (cmake .. -DBUILD_DEMO=ON). After this step we have Candle.sln project in build directory.

Now, if I just do cmake --build, I get this error:

(https://ltdfoto.ru/images/2023/03/15/error1.png)

I guess, compiler cant see SFML libraries, ok. Then I add it by myself in all 4 projects:
(https://ltdfoto.ru/images/2023/03/15/error2.png)

Everywhere it is possible I changed:

Configuration type: Dynamic library(.dll);
Additional library directories: ....\SFML-2.5.1\lib
Additional include directories: ....\SFML-2.5.1\include
Additional dependencies:  sfml-graphics-d.lib
                                      sfml-window-d.lib
                                      sfml-audio-d.lib
                                      sfml-system-d.lib


And copied everything from "/SFML-2.5.1/bin/" to project directory and build directory.
It doesnt build neither with "Ctrl+F5" in VS, not with "cmake --build .", I dont understand what I am doing wrong, please help.


Title: Re: SFML + CMake(VS 2022)
Post by: eXpl0it3r on March 15, 2023, 04:28:08 pm
See this thread (https://en.sfml-dev.org/forums/index.php?topic=24070.0) regarding the migration of CMake scripts, you shouldn't be using SFML_ROOT anymore.

Your error wasn't posted, so I don't know exactly what went wrong. :D