Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML + CMake(VS 2022)  (Read 913 times)

0 Members and 1 Guest are viewing this topic.

ToMadeira

  • Newbie
  • *
  • Posts: 1
    • View Profile
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.



eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10991
    • View Profile
    • development blog
    • Email
Re: SFML + CMake(VS 2022)
« Reply #1 on: March 15, 2023, 04:28:08 pm »
See this thread 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
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything