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

Author Topic: Building SFML project in Windows with CMake  (Read 3116 times)

0 Members and 1 Guest are viewing this topic.

Evan Bowman

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
    • Email
Building SFML project in Windows with CMake
« on: November 08, 2016, 10:09:07 pm »
I have a project that uses CMake, builds fine in macOS and Linux, but I'm having trouble getting it set up in windows (minGW)
The error  I'm getting is this:
Code: [Select]
CMake Error at cmake_modules/FindSFML.cmake:355 (message):
  SFML found but some of its dependencies are missing ( FreeType libjpeg
  OpenAL Ogg Vorbis VorbisFile VorbisEnc FLAC)
Call Stack (most recent call first):
  CMakeLists.txt:35 (find_package)

But I can see the dependencies alongside the sfml static libs:
Code: [Select]
$ ls /c/Program\ Files\ \(x86\)/SFML/lib/
libFLAC.a      libsfml-audio.a      libsfml-graphics-d.a    libsfml-network.a      libsfml-system-d.a    libsfml-window-s.a
libfreetype.a  libsfml-audio-d.a    libsfml-graphics-s.a    libsfml-network-d.a    libsfml-system-s.a    libsfml-window-s-d.a
libjpeg.a      libsfml-audio-s.a    libsfml-graphics-s-d.a  libsfml-network-s.a    libsfml-system-s-d.a  libvorbis.a
libogg.a       libsfml-audio-s-d.a  libsfml-main.a          libsfml-network-s-d.a  libsfml-window.a      libvorbisenc.a
libopenal32.a  libsfml-graphics.a   libsfml-main-d.a        libsfml-system.a       libsfml-window-d.a    libvorbisfile.a

From reading other forum posts, it looks like SFML needs to be linked statically in Windows, I am doing that:
Code: [Select]
set(SFML_STATIC_LIBRARIES ON)
find_package(SFML 2.4 REQUIRED graphics window network audio system)

For reference, here's the complete CMakeLists file that I'm using: https://github.com/evanbowman/blind-jump/blob/development/build/CMakeLists.txt

felaugmar

  • Guest
Re: Building SFML project in Windows with CMake
« Reply #1 on: November 09, 2016, 02:04:19 am »
I get this too when trying to link statically, maybe it's some configuration that need to be done;
But you're not restricted to link statically on Windows, you can link it with shared libs too.
« Last Edit: November 09, 2016, 02:01:18 pm by felaugmar »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
AW: Building SFML project in Windows with CMake
« Reply #2 on: November 09, 2016, 09:55:31 am »
You don't "have to" link statically on Windows. ;)

How should CMake know where to look for the SFML libraries? On Windows there's no real predefined place to place libraries. As such you simply need to specify a path to the root directory of SFML with SFML_ROOT.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Evan Bowman

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
    • Email
Re: Building SFML project in Windows with CMake
« Reply #3 on: November 12, 2016, 09:45:42 pm »
Thanks for both of your responses!

I'm still getting used to working without a centralized lib folder, I guess I've been spoiled by apt/rpm/homebrew :)