1
General / [SOLVED] Re: SFML integration via CMakeList.txt (static library)
« on: August 16, 2023, 09:22:38 pm »
so, I have treid your approach Trasher, at least for the dynamic library access it worked, but I couldnt use the BUILD_SHARED_LIBS command to configure static library generation.
But I had modified my original approach and the static generation via CMakeList.txt worked for me.
It worked without freetype library, unfortunatelly I still couldnt figure out why freetype cannot befound as mentioned before.
But I had modified my original approach and the static generation via CMakeList.txt worked for me.
It worked without freetype library, unfortunatelly I still couldnt figure out why freetype cannot befound as mentioned before.
cmake_minimum_required(VERSION 3.21)
project(sfml_static_include 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)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#set(BUILD_SHARED_LIBS FALSE)
#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_STATIC_LIBRARIES TRUE)
find_package(SFML COMPONENTS graphics window system REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
if(SFML_FOUND)
target_link_libraries(${PROJECT_NAME}
sfml-graphics
sfml-window
sfml-system
opengl32
winmm
gdi32
#freetype
)
endif()
project(sfml_static_include 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)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#set(BUILD_SHARED_LIBS FALSE)
#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_STATIC_LIBRARIES TRUE)
find_package(SFML COMPONENTS graphics window system REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
if(SFML_FOUND)
target_link_libraries(${PROJECT_NAME}
sfml-graphics
sfml-window
sfml-system
opengl32
winmm
gdi32
#freetype
)
endif()