I installed SFML with the command “apt install libsfml-dev”.
I can link it in cmake discribed like in this post “https://en.sfml-dev.org/forums/index.php?topic=24070.0” and everything works pretty fine.
But if I add set(SFML_STATIC_LIBRARIES TRUE) to my cmake file to link sfml static I get the following error:
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake:139 (message):
Requested SFML configuration (Static) was not found
Call Stack (most recent call first):
CMakeLists.txt:30 (find_package)
CMake Error at CMakeLists.txt:30 (find_package):
Found package configuration file:
/usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake
but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
FOUND.
I recognized that the SFMLConfig.cmake file wants to access a SFMLStaticTargets.cmake file in line 110, if I set(SFML_STATIC_LIBRARIES TRUE).
But my /usr/lib/x86_64-linux-gnu/cmake/SFML folder just contains the following files for Shared linking:
- SFMLConfig.cmake
- SFMLConfigDependencies.cmake
- SFMLConfigVersion.cmake
- SFMLSharedTargets.cmake
- SFMLSharedTargets-none.cmake
In sfml version I can download here “https://www.sfml-dev.org/download/sfml/2.5.1/” I can also just find these files in the lib/cmake/SFML folder, but a SFMLSharedTargets-release.cmake file instead of SFMLSharedTargets-none.cmake.
What can I do to static link sfml 2.5.1 in cmake?
2
Answers
I got the answer in the sfml Forum!
https://en.sfml-dev.org/forums/index.php?topic=26837
The error you got comes from
SFMLConfigDependencies.cmake
, more specifically the last few lines.The
sfml_bind_dependency
macro searches your system forlibXXX.so
, whereXXX
is one of theSEARCH_NAMES
.I think it suffices to install the
-dev
packages of the missing dependencies as follows: