1
General / SFML + CMake(VS 2022)
« 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:
I guess, compiler cant see SFML libraries, ok. Then I add it by myself in all 4 projects:
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.
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:
I guess, compiler cant see SFML libraries, ok. Then I add it by myself in all 4 projects:
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.