SFML community forums
Help => General => Topic started by: andraantariksa on October 10, 2020, 02:44:17 pm
-
So far, I have create this CMakeLists.txt
cmake_minimum_required (VERSION 3.8)
project ("CGA")
set(EXECUTABLE_NAME "cga")
add_executable(${EXECUTABLE_NAME}
CGA.cpp)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
set(SFML_DIR "cmake/")
set(SFML_ROOT "lib/SFML")
set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML COMPONENTS network audio graphics window system REQUIRED)
target_link_libraries(${EXECUTABLE_NAME}
${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
My directory structure
(https://i.imgur.com/YlLBH9U.png)
I get the SFMLConfig.cmake file from the repository (https://github.com/SFML/SFML/blob/master/cmake/SFMLConfig.cmake.in)
But I'm receiving some error.
(https://i.imgur.com/09MBlf8.png)
I'd like to be able to compile SFML and link it statically with my project using CMake. Can you help me to solve my problem?
-
Are you sure that you built static version of SFML?
-
If you build SFML as part of your CMake project you don't need to find_package it, as CMake already kowns the SFML targets. Instead you can just add SFML as subdirectory and then link sfml-<module>