So konfigurieren Sie TGUI + SFML mit CMakeC++

Programme in C++. Entwicklerforum
Anonymous
 So konfigurieren Sie TGUI + SFML mit CMake

Post by Anonymous »

Ich arbeite derzeit an einem Projekt und habe mich entschieden, TGUI mit SFML zum Erstellen eines Menüs zu verwenden. SFML funktioniert gut mit CMake und ich dachte, dass die Konfiguration von TGUI ziemlich dasselbe wäre, bin mir aber nicht sicher ... Wie konfiguriere ich TGUI?
Mein Code sieht im Moment so aus:

Code: Select all

#documentation for configuring SFML with CMake : https://en.sfml-dev.org/forums/index.php?topic=24070.0

cmake_minimum_required(VERSION 3.17.3)
set(CMAKE_CXX_STANDARD 14)

project(AlgorithmsSimulator)

#location of project's files
include_directories(${CMAKE_SOURCE_DIR})

#directory for excutables
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

#object files
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)

#configuring SFML for windows
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS TRUE)
set(SFML_STATIC_LIBRARIES TRUE)
set(SFML_DIR "./SFML_Win/lib/cmake/SFML")

#MacOS
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
set(SFML_INCLUDE_DIR "./SFML_macOS/include")
set(SFML_LIBRARY_DIR "./SFML_macOS/lib")
link_directories(SFML_LIBRARY_DIR)
include_directories(SFML_INCLUDE_DIR)

#Linux
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
#set(SFML_STATIC_LIBRARIES TRUE)
set(SFML_DIR "./SFML_Linux/lib/cmake/SFML")

else()
message(FATAL_ERROR "Your Operating System is not supported")
endif()

# TGUI configuration
set(TGUI_DIR "./TGUI/lib/cmake/TGUI")

#after configuring the paths of sfml for windows, macOS and linux cmake needs only to find the below packages
find_package(SFML 2.5 COMPONENTS audio graphics window system network REQUIRED)
find_package(TGUI 0.8 REQUIRED)

#compiling & list the header an source files in the solution explorer
set(HEADERS AlgorithmsImplementation.h)
set(SOURCES AlgorithmsImplementation.cpp Main.cpp)
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES})

# sfml .dll files and the .dll files for tgui; when tgui-d is added I get this linking error: tgui-d.lib cannot be opened and when I exclude it, it says that it cannot found tgui-d.dll
target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system sfml-network tgui tgui-d)

#this will allow us to install an .exe file of the project
install(TARGETS ${PROJECT_NAME} DESTINATION bin) #${CMAKE_INSTALL_PREFIX}/bin
install(FILES Main.cpp DESTINATION src)          #${CMAKE_INSTALL_PREFIX}/src

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post