Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - ChupiChulio

Pages: [1]
1
General / [SOLVED]SFML integration via CMakeList.txt (static library)
« on: August 10, 2023, 11:07:16 am »
Hello together,

I am relatively new to this topic and trying to get SFML running in my environment.

Currently I have tried the console commands, as in tutorials on SFML website and it worked fine.
For static library generation as well, using with -s attached ;
g++ main.o -o sfml-app -L<sfml-install-path>/lib -lsfml-graphics-s -lsfml-window-s -lsfml-system-s

Now I have tried to trigger the whole proccess via CMakeList.txt in VSCode, I made it so far executing the example using dynamic library access (dll must be present within the same folder as .exe file)
Now two points here:
  • I am not sure how to implement static library in my CMakeList.txt file, to get rid of extra dll files ?
  • When executing .exe I am getting terminal window opened in background, how to get rid of it ?

Thank you

cmake_minimum_required(VERSION 3.0.0)
project(sfml_cmake_headers VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

set(CMAKE_CXX_STANDARD 14)

#If you are using Windows, manually set the location where you installed SFML.
set(SFML_DIR "C:/Users/User/Documents/Libraries/SFML-2.6.0/lib/cmake/SFML")
#set(SFML_INCLUDE_DIR "C:/Users/User/Documents/Libraries/SFML-2.6.0/include/SFML")
   

add_executable(${PROJECT_NAME} main.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../Users/User/Documents/Libraries/SFML-2.6.0/include)


find_package(SFML COMPONENTS network audio graphics window system REQUIRED)
if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR})
  # SFML version >= 2.5
  #In SFML Version 2.5 or later, ${SFML_LIBRARIES}, ${SFML_DEPENDENCIES}, ${SFML_INCLUDE_DIR} no longer exist. Specify libraries individually.
  target_link_libraries(sfml_cmake_headers sfml-network sfml-audio sfml-graphics sfml-window sfml-system)
endif()
 

Pages: [1]