I do have the following CMakeLists.txt
:
cmake_minimum_required(VERSION 3.10)
project(testovnik)
include_directories(include)
file(GLOB SOURCES "src/*.cpp" "include/*.hpp")
file(GLOB TESTS "tests/*.cpp")
set(EXECUTABLE_NAME "testovnik")
add_executable(${EXECUTABLE_NAME} ${SOURCES})
if(WIN32)
set(SFML_ROOT "C:/lib/SFML")
endif()
set_target_properties(${EXECUTABLE_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML 2 REQUIRED graphics window system)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
endif()
When I do cmake
on Windows, it works perfectly. Creates a .sln
, then I can go build the whole project and it works. Now I want to do the same on Linux, necessarily linking it statically. But it doesn't work. I get the following error:
[frynio@manjaro bin]$ cmake ..
CMake Error at /usr/share/cmake-3.10/Modules/FindSFML.cmake:355 (message):
Could NOT find SFML (missing: SFML_GRAPHICS_LIBRARY SFML_WINDOW_LIBRARY
SFML_SYSTEM_LIBRARY)
Call Stack (most recent call first):
CMakeLists.txt:22 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/frynio/projects/cpp/testovnik_cpp/bin/CMakeFiles/CMakeOutput.log".
If I comment/delete the line set(SFML_STATIC_LIBRARIES TRUE)
then it works. I can change it to set(SFML_STATIC TRUE)
, then it also works, make
works too. But if I make the project, I get the executable, but still if I uninstall sfml (sudo pacman -R sfml
) then I get the following error when trying to launch it:
[frynio@manjaro bin]$ ./testovnik
./testovnik: error while loading shared libraries: libsfml-graphics.so.2.4: cannot open shared object file: No such file or directory
Is there any way to build my project and give it to somebody else without them having to have sfml
installed?