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

Author Topic: Trouble "Compiling" with Cmake  (Read 4806 times)

0 Members and 1 Guest are viewing this topic.

ApianbelleDev

  • Newbie
  • *
  • Posts: 6
    • View Profile
Trouble "Compiling" with Cmake
« on: May 11, 2021, 02:17:32 am »
short question: I need help compiling sfml via cmake.

long question: Hi! I am creating a 3d RPG in C++ because I want to have more control with pretty much everything, and I want to learn more about C++ in the process. anyways, I have been trying to "compile" sfml with Cmake, and i'm getting frustrated enough to ask for help. I have been trying for weeks, but to no avail

coding in SFML is not a problem, cause I use it on Linux all the time. but I want the game to be for windows, with the ability to port it to consoles and older handhelds.

the SFML docs do not make sense at all of what to do to get the CMakeLists.txt file, in order to build sfml for use with MinGW. I do not want to use an IDE if not possible, because I am used to Linux-style compiling.

if anyone would link to an easy-to-follow tutorial or give me some pointers, that would be great.

or if anyone would be willing to tell me a "simpler to set up in windows" library that would be great too.
« Last Edit: May 11, 2021, 06:15:25 am by ApianbelleDev »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Trouble "Compiling" with Cmake
« Reply #1 on: May 11, 2021, 02:37:56 am »
Using CMake is not exclusive to SFML, so you can find a lot of resources out there, starting with the official documentation: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html

From there the following thread might help you on how to use SFML with your project: https://en.sfml-dev.org/forums/index.php?topic=24070.0
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ApianbelleDev

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Trouble "Compiling" with Cmake
« Reply #2 on: May 11, 2021, 02:40:13 am »
alright. I'll try this. thanks

ApianbelleDev

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Trouble "Compiling" with Cmake
« Reply #3 on: May 11, 2021, 05:55:44 am »
alright. just to make sure I am on the right track, this is my cmakelists file.

# include the SFML specific macros
include($C:\Users\Mirac\Desktop\Projects\code\C++\Project Excalibur/Cmake/Macros.cmake)

# let CMake know about our additional libraries paths
if (SFML_OS_WINDOWS)
    set(CMAKE_INCLUDE_PATH $C:\msys64\mingw64\include "$C:\Users\Mirac\Desktop\Projects\code\C++\Project Excalibur/extlibs/headers")
    if(SFML_COMPILER_GCC)
        if(ARCH_32BITS)
            set(CMAKE_LIBRARY_PATH $C:\msys64\mingw64\lib "$C:\Users\Mirac\Desktop\Projects\code\C++\Project Excalibur/extlibs/libs-mingw/x86")
            set(CMAKE_LIBRARY_PATH $C:\msys64\mingw64\include"$C:\Users\Mirac\Desktop\Projects\code\C++\Project Excalibur/extlibs/bin/x86")
        elseif(ARCH_64BITS)
            set(CMAKE_LIBRARY_PATH $C:\msys64\mingw64\lib} "$C:\Users\Mirac\Desktop\Projects\code\C++\Project Excalibur/extlibs/libs-mingw/x64")
            set(CMAKE_LIBRARY_PATH $C:\msys64\mingw64\lib} "$C:\Users\Mirac\Desktop\Projects\code\C++\Project Excalibur/extlibs/bin/x64")
        endif()

if I'm not on the right track, could someone maybe point me on the right one?  :>

ApianbelleDev

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Trouble "Compiling" with Cmake
« Reply #4 on: May 11, 2021, 06:09:42 am »
Nevermind about everything. it seems I was overcomplicating everything. I just copied the include files to my project and it is working. didn't have to compile anything with CMake.


I should have done this in the beginning. I don't know why I didn't do this at the beginning lol.

ApianbelleDev

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Trouble "Compiling" with Cmake
« Reply #5 on: May 11, 2021, 06:18:03 am »
nope nope, nevermind about that last part. sorry for being difficult, but I still can't get it to work. in vs code the errors were gone, but when compiling via mingw, it says fatal error: SFML/Graphics.hpp: No Such file or directory. I don't want to use CMake if I don't have to, but I also don't want to use an IDE if I don't have to. if I really have to though, I'd choose to use an IDE. I just don't want to do this for reasons that I stated above.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Trouble "Compiling" with Cmake
« Reply #6 on: May 11, 2021, 08:02:56 am »
Why do you want to compile SFML? There are precompiled releases for MinGW on the download page. You'd have to compile SFML yourself only if none is compatible with your version of MinGW.

Once you have a working SFML, you don't need to use CMake either. CMake is just what we use to build SFML. You can write a makefile or whatever, all you have is a set of headers and libraries, like with any other C++ library.

If you know how to use it on Linux then there's nothing different on Windows with MinGW.
Laurent Gomila - SFML developer

ApianbelleDev

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Trouble "Compiling" with Cmake
« Reply #7 on: May 12, 2021, 03:20:54 am »
OHHH, I was under the impression that I had to use CMake to use it on mingw, whoops. my mistake. some people on other forums just told me I had to use CMake to use it with mingw. they are idiots. sorry for the trouble!