Hi all,
I'm trying to get a project built using QTCreator and CMake.
I've successfully run the CMake gui and mingw-32 to build SFML in D:/SFML, and now I'm trying to make a simple QTCreator project that includes some SFML libraries. My CMakeLists is as follows:
cmake_minimum_required(VERSION 3.1)
project(Learning)
set(SFML_DIR "D:/SFML/lib/cmake/SFML")
find_package(SFML 2.5 COMPONENTS graphics audio system REQUIRED)
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(SFMLTest sfml-graphics sfml-audio)
When I ask QTCreator to run CMake, it gives me the following error:
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:/SFML/lib/cmake/SFML/SFMLConfig.cmake, version: 2.5.1 (32bit)
As far as I can tell, I've exactly followed the sticky post in this forum about migrating to SFML 2.5+... any ideas what could be going wrong? I'm a few days into google searching for help, with no luck.
I've advanced the problem a bit, but still can't get a simple program to run.
I did the following, in order:
1) Got SFML source from github
2) Ran CMake, producing mingw32 makefile
3) Ran mingw32-make in the build directory, successfully building SFML
4) Created a QTCreator project, picked mingw32 as the compiler
5) Produced the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.1)
project(LearnCMake)
set(SFML_DIR D:/Programming/Libraries/SFML)
find_package(SFML COMPONENTS window system REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} sfml-window sfml-system)
6) Successfully built the program with QTCreator
When I run the project from QTCreator, it says:
"The program has unexpectedly finished."
Do I need to move/copy the libraries of interest out of the SFML build directory and into my project or something? So many hours... so close...
@eXplo0it3r: Following your response and some other reading, I've made sure to use the same compiler for both. My SFML libraries are located at D:\Programming\Libraries\SFML\lib
Update:
I ran CMake again to configure it to build static libraries and included
set(SFML_STATIC_LIBRARIES TRUE)
in my CMakeLists.txt file and, voila, the program runs and I have a window!
I'm still curious to know what I was doing wrong with dynamic libraries, though.