Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to setup CMake in Visual Studio?  (Read 1728 times)

0 Members and 1 Guest are viewing this topic.

andraantariksa

  • Newbie
  • *
  • Posts: 1
    • View Profile
How to setup CMake in Visual Studio?
« 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



I get the SFMLConfig.cmake file from the repository

But I'm receiving some error.



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?

Kvaz1r

  • Newbie
  • *
  • Posts: 39
    • View Profile
    • Email
Re: How to setup CMake in Visual Studio?
« Reply #1 on: October 14, 2020, 03:44:28 pm »
Are you sure that you built static version of SFML?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: How to setup CMake in Visual Studio?
« Reply #2 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>
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/