SFML community forums

Help => General => Topic started by: andraantariksa on October 10, 2020, 02:44:17 pm

Title: How to setup CMake in Visual Studio?
Post by: andraantariksa on October 10, 2020, 02:44:17 pm
So far, I have create this CMakeLists.txt

Quote
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?
Title: Re: How to setup CMake in Visual Studio?
Post by: Kvaz1r on October 14, 2020, 03:44:28 pm
Are you sure that you built static version of SFML?
Title: Re: How to setup CMake in Visual Studio?
Post by: eXpl0it3r on October 14, 2020, 06:07:53 pm
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>