I'm trying to use SFML on Windows 10 with CLion as my IDE - this is CMake based with the Ninja generator. I'm using the MSVC2022 x64 toolchain. Although I can build the SFML library (from source - master branch, which I believe is version 3.0) I can't get my project to build.
I get the following error:
"C:\Program Files\JetBrains\CLion 2022.1\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2022.1/bin/ninja/win/ninja.exe" -G Ninja -S D:\cs4300\a2 -B D:\cs4300\a2\cmake-build-debug
CMake Error at D:/Software/SFML/sfml-install/lib/cmake/SFML/SFMLConfig.cmake:150 (message):
Found SFML but requested component 'audio' is missing in the config defined
in D:\Software\SFML\SFML-install\lib\cmake\SFML.
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)
CMake Error at CMakeLists.txt:11 (find_package):
Found package configuration file:
D:/Software/SFML/SFML-install/lib/cmake/SFML/SFMLConfig.cmake
but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
FOUND.
-- Configuring incomplete, errors occurred!
See also "D:/cs4300/a2/cmake-build-debug/CMakeFiles/CMakeOutput.log".
My CMakeLists.txt includes:
find_package(SFML 3 COMPONENTS system window network graphics audio REQUIRED)
list(APPEND THIRD_PARTY_LIBS sfml-system)
list(APPEND THIRD_PARTY_LIBS sfml-window)
list(APPEND THIRD_PARTY_LIBS sfml-network)
list(APPEND THIRD_PARTY_LIBS sfml-graphics)
list(APPEND THIRD_PARTY_LIBS sfml-audio)
add_executable(sfml_game main.cpp ..others..)
target_link_libraries(sfml_game PRIVATE ${THIRD_PARTY_LIBS})
If I compile the SFML 2.5.1 source, I get different errors. I can run the program (obviously changing the SFML version for find_package) but it crashes as unable to load a font and spits out a load of odd symbols in the error message too.
I'm compiling with (and also tried -DBUILD_SHARED_LIBS=OFF):
mkdir SFML-build
cd SFML-build
cmake -GNinja ..\SFML-master
ninja all
cmake --install . --prefix ..\SFML-install
I've spent all day trying to get this to work, which is extremely frustrating as my other computer as a mac where it just works. Any assistance getting this to compile and link would be much appreciated.