Hello, I'm currently trying to integrate TGUI into my SFML project. I'm using CMake and VS Code, but I've encountered a problem where TGUI can't find SFML. I have the error message ready here, which mentions setting the SFML_DIR, but I'm not sure exactly where to do that. Any help would be greatly appreciated.
I have integrated TGUI into my project as follows:
and SFML is not directly in the project folder, but it usually finds it after setting the SFML_DIR.
My CMakeLists.txt from the main project:
Code Select
[main] Building folder: AutoBackupScript2
[main] Configuring project: AutoBackupScript2
[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 -SC:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/TGUI -Bc:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake]
[cmake] Searching for SFML 2...
[cmake]
[cmake] -- Could NOT find SFML (missing: SFML_DIR)
[cmake]
[cmake] Searching for SFML 3...
[cmake]
[cmake] -- Could NOT find SFML (missing: SFML_DIR)
[cmake] CMake Error at cmake/Dependencies.cmake:80 (message):
[cmake] CMake couldn't find SFML.
[cmake]
[cmake] Set SFML_DIR to the directory containing SFMLConfig.cmake (usually
[cmake] something like SFML_ROOT/lib/cmake/SFML)
[cmake]
[cmake] Call Stack (most recent call first):
[cmake] cmake/Dependencies.cmake:93 (tgui_find_dependency_sfml)
[cmake] src/Backend/CMakeLists.txt:153 (tgui_add_dependency_sfml)
[cmake] src/CMakeLists.txt:305 (include)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[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 -SC:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/TGUI -Bc:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build -G "MinGW Makefiles" exited with code: 1
I have integrated TGUI into my project as follows:
Code Select
Project/
├── CMakeLists.txt (Main project)
├── src/
│ └── main.cpp
└── TGUI/
and SFML is not directly in the project folder, but it usually finds it after setting the SFML_DIR.
My CMakeLists.txt from the main project:
Code Select
cmake_minimum_required(VERSION 3.17)
project(AutoBackupScript VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
# Füge die Quelldateien hinzu
set(SOURCES
src/main.cpp
)
include_directories(headers)
# Füge das ausführbare Ziel hinzu und verlinke ImGui
add_executable(AutoBackupScript ${SOURCES})
#target_link_libraries(AutoBackupScript PRIVATE TGUI)
# Suche und verlinke SFML
set(SFML_DIR "c:/SFML/lib/cmake/SFML") # Pfad zum SFML CMake-Modul
find_package(SFML COMPONENTS system window graphics network audio REQUIRED)
if (SFML_FOUND)
target_link_libraries(AutoBackupScript PRIVATE sfml-system sfml-window sfml-graphics sfml-network sfml-audio)
endif()
#target_link_libraries(AutoBackupScript PRIVATE TGUI)
set(SFML_DIR "c:/SFML/lib/cmake/SFML")
#include_directories(${CMAKE_SOURCE_DIR}/TGUI)
#include_directories(${CMAKE_SOURCE_DIR})
#add_subdirectory(TGUI)
#find_package(TGUI 1 REQUIRED)
#target_link_libraries(AutoBackupScript PRIVATE TGUI::TGUI)
# Kopiere DLLs in das Build-Verzeichnis
if(WIN32)
file(GLOB BINARY_DEP_DLLS "c:/SFML/bin/*.dll")
file(COPY ${BINARY_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
file(GLOB MINGW_DEP_DLLS "C:/mingw64/bin/*.dll")
file(COPY ${MINGW_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
endif()