I am trying to create a project template for future SFML projects, featuring CMake.
My SFML folder that I downloaded is located at D:/Dev/Libraries/SFML-2.5.1/
I already built SFML with CMake with this tutorial.
My sfml-project
folder structure is as below:
root
+- build
+- src
| +- main.cpp
+- CMakeLists.txt
The contents of CMakeLists.txt
:
cmake_minimum_required(VERSION 3.21.1)
set(PROJECT_NAME sfml-project)
set(EXECUTABLE_NAME main)
set(SFML_DIR D:/Dev/Libraries/SFML-2.5.1/build)
project(${PROJECT_NAME} LANGUAGES CXX)
find_package(SFML 2.5.1 COMPONENTS graphics system window)
file(GLOB SOURCES src/*.cpp)
add_executable(${EXECUTABLE_NAME} ${SOURCES})
target_link_libraries(${EXECUTABLE_NAME} sfml-system sfml-window sfml-graphics)
When I do cmake ..
in the build
subdirectory it runs smoothly:
$ cmake ..
-- Found SFML 2.5.1 in D:/Dev/Libraries/SFML-2.5.1/build
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Dev/Project Templates/sfml-project/build
However, when I use mingw32-make
afterwards it says:
mingw32-make[2]: *** No rule to make target 'D:/Dev/Libraries/SFML-2.5.1-build/lib/libsfml-graphics.a', needed by 'main.exe'. Stop.
mingw32-make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/main.dir/all] Error 2
mingw32-make: *** [Makefile:90: all] Error 2
What is the issue here? Is it the CMakeLists.txt
file that messed up? Or does it have something to do with how I downloaded and built SFML?
I have tried to copy all the .dll
and .a
files from the original SFML-2.5.1/build/lib
folder, but the problem persists.
I figured it out. Instead of running mingw32-make
in the building SFML with CMake tutorial, I had to do mingw32-make install
.