SFML community forums

Help => General => Topic started by: stav on March 18, 2019, 09:03:04 am

Title: SFML_FOUND get set to NOT_FOUND ?
Post by: stav 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?
Title: Re: SFML_FOUND get set to NOT_FOUND ?
Post by: Laurent 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?
Title: Re: SFML_FOUND get set to NOT_FOUND ?
Post by: stav 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