CMake Error Code 1: Troubleshooting Build Issue with SFML and MinGW

Hello fellow developers,

I hope you’re all doing well. I’m currently working on one of my first projects using SFML and CMake, and I’ve run into an issue that I could use some help with. What’s puzzling is that the program ran successfully before I copied it to use as a setup for a new project.

When I attempt to generate the build files for my project using CMake, I receive the following error message:

[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" -SC:/Users/luka-/OneDrive/Desktop/GameOfLife -Bc:/Users/luka-/OneDrive/Desktop/GameOfLife/build -G "MinGW Makefiles" -A x64 exited with code: 1

I’ve tried to troubleshoot this issue on my own, but I’m currently stuck, and I’m hoping that the collective wisdom of this community can help me figure out what’s going wrong.

Here are some details about my setup and what I’ve tried so far:

  • CMake Version: I’m using CMake version 3.27.1.
  • Paths: I’ve double-checked the paths in my CMake command, and they appear to be correct.
  • Generator Option: I’m specifying the “MinGW Makefiles” generator, which should be suitable for my MinGW setup.
  • CMakeLists.txt: I’ve included my CMakeLists.txt file below, and it seems to be correctly configured.
  • Dependencies: I’ve confirmed that SFML is installed correctly.
  • DLLs: I’m copying the necessary DLLs to the build directory as part of my build process.
cmake_minimum_required(VERSION 3.17)



add_executable(GameOfLife ${SOURCES})



find_package(SFML REQUIRED system window graphics network audio)

    target_include_directories(GameOfLife PRIVATE ${SFML_INCLUDE_DIR})
    target_link_libraries(GameOfLife PRIVATE ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})


    file(GLOB BINARY_DEP_DLLS "${SFML_INCLUDE_DIR}/../bin/*.dll")
    file(GLOB MINGW_DEP_DLLS "C:/mingw64/bin/*.dll")

I’ve also confirmed that there are no typos in my command or paths, and SFML is correctly installed.

I’m stumped at this point, and I would greatly appreciate any insights, suggestions, or advice on how to resolve this issue. If you need any more information or logs to help diagnose the problem, please let me know, and I’ll provide them promptly.

Thank you all in advance for your assistance!

Best regards,

There should be some other output in the area that indicates the actual error (usually “CMake Error” is involved). There’s not enough here to diagnose without doing all of the dependency and toolchain setup here (and any error in that setup may mask/distract from the error you’re seeing).

Thank you for your response, and I appreciate the help. I completely understand that there may be more detailed error messages hidden within the CMake output. I apologize for not providing the complete output initially.

I’ve included all the information I found in the CMake output. If there are additional steps or specific commands I should run to gather more details, I would greatly appreciate an explanation of how to do so.

[proc] Executing command: cmake --version
[proc] Executing command: cmake -E capabilities
[variant] Loaded new set of variants
[kit] Successfully loaded 5 kits from C:\Users\luka-\AppData\Local\CMakeTools\cmake-tools-kits.json
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --version
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -E capabilities
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -SC:/Users/luka-/OneDrive/Desktop/GameOfLife -Bc:/Users/luka-/OneDrive/Desktop/GameOfLife/build -G "MinGW Makefiles" -A x64
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" -SC:/Users/luka-/OneDrive/Desktop/GameOfLife -Bc:/Users/luka-/OneDrive/Desktop/GameOfLife/build -G "MinGW Makefiles" -A x64 exited with code: 1
[main] Configuring project: GameOfLife 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\mingw64\bin\g++.exe "-DCMAKE_GENERATOR:STRING=MinGW Makefiles" -DCMAKE_GENERATOR_PLATFORM:STRING=x64 -SC:/Users/luka-/OneDrive/Desktop/GameOfLife -Bc:/Users/luka-/OneDrive/Desktop/GameOfLife/build
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Configuring incomplete, errors occurred!
[cmake] CMake Error at CMakeLists.txt:2 (project):
[cmake]   Generator
[cmake]     MinGW Makefiles
[cmake]   does not support platform specification, but platform
[cmake]     x64
[cmake]   was specified.
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\mingw64\bin\g++.exe "-DCMAKE_GENERATOR:STRING=MinGW Makefiles" -DCMAKE_GENERATOR_PLATFORM:STRING=x64 -SC:/Users/luka-/OneDrive/Desktop/GameOfLife -Bc:/Users/luka-/OneDrive/Desktop/GameOfLife/build exited with code: 1

Whatever is passing -DCMAKE_GENERATOR_PLATFORM:STRING=x64 needs to drop that. This variable only means something to IDE generators. The MinGW Makefiles generator relies on the compilers selected to determine the target platform.

I appreciate your patience. I want to clarify that I’m using the Visual Studio Code CMake extension (not the CMake GUI), and I’m not entirely sure how to remove the -DCMAKE_GENERATOR_PLATFORM:STRING=x64 setting within the extension.

The cmakeSettings.json file I’ve shared is what I have access to within the extension, and I’ve already removed the setting from there as suggested. However, it seems that the issue persists despite these changes.

Is there a specific step or configuration within the Visual Studio Code CMake extension that I might be missing? I’d greatly appreciate any further advice on how to ensure that this platform specification is not included in the CMake generation process when using the extension.

Unfortunately, I’m currently unable to compile my old project. it triggers the same error. I dont know what to do

I’m not familiar with VSCode enough to help more. I think it might be worth trying to do the initial configure manually and then point VSCode to that build tree?