2

I'm trying to build a C++ project with CMake 64-bit for Windows and SFML 2.5.1 64-bit. When I run cmake on the project I'm getting an error message.

The only way I can get it to work is to change the CMAKE_PREFIX_PATH to point to a 32-bit version of SFML but that's not what I want.

CMakeLists.txt:

cmake_minimum_required (VERSION 3.8)

#project(GameOfLife)

set(CMAKE_PREFIX_PATH "D:\\Program Files\\SFML-2.5.1\\lib\\cmake\\SFML")

find_package(SFML 2.5 COMPONENTS graphics window REQUIRED)

# Add source to this project's executable.
add_executable (GameOfLife "GameOfLife.cpp" "GameOfLife.h")

# Link SFML
target_link_libraries(GameOfLife sfml-graphics sfml-window)

Error message:

CMake Error at CMakeLists.txt:16 (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:

D:/Program Files/SFML-2.5.1/lib/cmake/SFML/SFMLConfig.cmake, version: 2.5.1 (64bit)

Kyle V.
  • 4,752
  • 9
  • 47
  • 81
  • 2
    Wether or not CMake is 64bit doesn't matter in that case. Your toolchain has to be configured to build 64bit binaries. From the error and your description of a workaround, it seems you are using a 32bit toolchain. – Stanley F. Feb 15 '19 at 05:52
  • How do I use a 64bit toolchain then? – Kyle V. Feb 15 '19 at 14:39

2 Answers2

1

I faced with the same problem and after some investigation I understood that Stanley's comment was correct. To use a 64-bit toolchain just run:

cmake -G "Visual Studio 15 2017 Win64" ..

For 32-bit SFML version it is enough to run simply: cmake ..

Lex Sergeev
  • 231
  • 1
  • 3
  • 17
0

This issue happened to me on CLion, in my case I downloaded SFML for MinGW-64, but the default toolchain was configured to Visual Studio.

I solved this by going to File->Settings->Build, Execution, Deployment->Toolchains, clicking on MinGW and then the up arrow, making MinGW the defaut toolchain.