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

Author Topic: SFML_FOUND get set to NOT_FOUND ?  (Read 3602 times)

0 Members and 1 Guest are viewing this topic.

stav

  • Newbie
  • *
  • Posts: 10
    • View Profile
SFML_FOUND get set to NOT_FOUND ?
« on: March 18, 2019, 09:03:04 am »
Hi
I'm on windows and im trying to setup SFML with a cmake script.

CMakeLists.txt:
Code: [Select]
cmake_minimum_required(VERSION 3.12.1 )
project(Towdef)

add_definitions(-DDEBUG_BUILD)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

set(SFML_DIR "C:/Users/vatsug/SFML-2.5.1/cmake")
find_package(SFML 2.5 COMPONENTS graphics network audio window system REQUIRED)

set(sfml-libs
    sfml-graphics
    sfml-network
    sfml-audio
    sfml-window
    sfml-system
  )

file(GLOB SOURCES *.cpp)

add_executable(Towdef ${SOURCES})
target_link_libraries(Towdef ${sfml-libs})


When i run it i get the following error:
Code: [Select]
CMake Error at CMakeLists.txt:9 (find_package):
  Could not find a configuration file for package "SFML" that is compatible
  with requested version "2.5".

  The following configuration files were considered but not accepted:

    C:/Users/vatsug/SFML-2.5.1/cmake/SFMLConfig.cmake, version: unknown

And when i remove the 2.5 from find_package i get this error:
Code: [Select]
CMake Error at CMakeLists.txt:9 (find_package):
  Found package configuration file:

    C:/Users/vatsug/SFML-2.5.1/cmake/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.

What am i doing wrong?
Thanks for reading.

EDIT:
oh and another question:
In order to get this to work in the first place i had to go in to my sfml/cmake directory and rename the SFMLConfig.cmake.in to SFMLConfig.cmake

otherwise cmake couldn't find it. Is there a reason that it has a .in postfix?
« Last Edit: March 18, 2019, 10:55:15 am by stav »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML_FOUND get set to NOT_FOUND ?
« Reply #1 on: March 18, 2019, 01:13:05 pm »
SFMLConfig.cmake.in is the template file that is used when SFML is built, to generate the actual configuration file that you must use -- which is named SFMLConfig.cmake. So you're looking at the wrong file.

Did you download or built SFML?
Laurent Gomila - SFML developer

stav

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: SFML_FOUND get set to NOT_FOUND ?
« Reply #2 on: March 21, 2019, 03:12:24 pm »
ah sorry im an idiot
im fairly new to cmake and i didnt know i had to generate it first.

problem solved. Thank you
« Last Edit: March 22, 2019, 04:35:10 pm by stav »