SFML community forums

Help => General => Topic started by: Evan Bowman on November 08, 2016, 10:09:07 pm

Title: Building SFML project in Windows with CMake
Post by: Evan Bowman 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
Title: Re: Building SFML project in Windows with CMake
Post by: felaugmar 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.
Title: AW: Building SFML project in Windows with CMake
Post by: eXpl0it3r 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.
Title: Re: Building SFML project in Windows with CMake
Post by: Evan Bowman 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 :)