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

Author Topic: Adding Candle to an existing SFML project (SFML / CMAKE)  (Read 218 times)

0 Members and 1 Guest are viewing this topic.

rousie

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Adding Candle to an existing SFML project (SFML / CMAKE)
« on: November 09, 2023, 09:26:52 am »
Okay, So I'm setting up a practice project for SFML and I was able to figure my way around building and running it (an empty window for now) with Cmake in Xcode. Now I was trying to add the Candle library to it, but whenever I tried building Candle with the given instructions I encountered an error) and I cant seem to even build the Candle library, even if I go into the Candle folder and try to build it as instructed on git.

I mean I can try to figure out how to do some lighting with the basic SFML, but it would be amazing to play around with Candle as well.

Never worked with SFML, Cmake or Xcode before lol. Previously I have only worked with Makefiles and used VScode, so I think it's just something simple yet fundamental that I'm missing.

My file/foldersturcture in the root was:
CmakeLists.txt
CmakeFiles
CmakeScripts
SFMLpractice.xcodeproj
_deps
build
bin
includes
--->in which I had the Candle cloned from git
srcs
--->in which I had my main.cpp to see if the window opens / In the main I Included includes/candle/RadialLight.hpp for the header

Linked I have my Cmake file to build the SFML and link the main with it. I thought I could build the Candle library in the subfolder and then just link it to the Cmake file I have on the upper level to build the project itself, but I think that is not the case after all.

Any tips, tricks or other notes would be greatly appreciated.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Adding Candle to an existing SFML project (SFML / CMAKE)
« Reply #1 on: November 10, 2023, 04:01:07 pm »
Can you provide the errors that you're getting? Otherwise it's kind of hard to know what is going wrong exactly.

Looking at you CMakeLists.txt I see that you're only fetching the header files from the include directory. But if you have Candle cloned in full within the include directory, then you also need to include the *.cpp files, otherwise you can't build Candle.

Probably the better option is to just do a FetchContent as you have done for SFML.
Or at least build Candle as separate library with add_subdirectory and don't just try to cram it into your own source tree.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything