Skip to content

Commit

Permalink
Adjustments for finding SFML
Browse files Browse the repository at this point in the history
- SFML 2.5 and newer install a CMake config module so FindSFML.cmake is no longer needed.
- Additionally detect SFML 3 vs SFML 2 and use the correct target names for linking.
  • Loading branch information
Blzut3 committed Dec 24, 2024
1 parent 8e0ff3a commit 0604cac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 218 deletions.
209 changes: 0 additions & 209 deletions cmake/find_modules/FindSFML.cmake

This file was deleted.

15 changes: 11 additions & 4 deletions cmake/unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ find_package(wxWidgets ${WX_VERSION} COMPONENTS ${WX_LIBS} REQUIRED)
include(${wxWidgets_USE_FILE})

# SFML
set(SFML_FIND_COMPONENTS system audio window network)
set(SFML_FIND_COMPONENTS System Audio Window Network)
list(TRANSFORM SFML_FIND_COMPONENTS TOLOWER OUTPUT_VARIABLE SFML2_FIND_COMPONENTS)
find_package(SFML 2 QUIET COMPONENTS ${SFML2_FIND_COMPONENTS})
if(SFML_FOUND)
list(TRANSFORM SFML2_FIND_COMPONENTS PREPEND sfml- OUTPUT_VARIABLE SFML_LIBRARIES)
else()
list(TRANSFORM SFML_FIND_COMPONENTS PREPEND SFML:: OUTPUT_VARIABLE SFML_LIBRARIES)
find_package(SFML 3 COMPONENTS ${SFML_FIND_COMPONENTS} REQUIRED)
endif()

find_package(Freetype REQUIRED)
find_package(FTGL REQUIRED)

Expand All @@ -92,15 +101,13 @@ else(NO_FLUIDSYNTH)
endif()

find_package(FreeImage REQUIRED)
find_package(SFML COMPONENTS ${SFML_FIND_COMPONENTS} REQUIRED)
find_package(OpenGL REQUIRED)
if (NOT NO_LUA)
find_package(Lua REQUIRED)
endif()
find_package(MPG123 REQUIRED)
include_directories(
${FREEIMAGE_INCLUDE_DIR}
${SFML_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIRS}
${FTGL_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
Expand Down Expand Up @@ -157,7 +164,7 @@ target_link_libraries(slade
${EXTERNAL_LIBRARIES}
${wxWidgets_LIBRARIES}
${FREEIMAGE_LIBRARIES}
${SFML_LIBRARY}
${SFML_LIBRARIES}
${FREETYPE_LIBRARIES}
${FTGL_LIBRARIES}
${OPENGL_LIBRARIES}
Expand Down
16 changes: 11 additions & 5 deletions cmake/win_msvc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ endif ()
find_package(freeimage CONFIG REQUIRED)
find_package(MPG123 CONFIG REQUIRED)
find_package(OpenGL REQUIRED)
find_package(SFML COMPONENTS system audio window network CONFIG REQUIRED)

set(SFML_FIND_COMPONENTS System Audio Window Network)
list(TRANSFORM SFML_FIND_COMPONENTS TOLOWER OUTPUT_VARIABLE SFML2_FIND_COMPONENTS)
find_package(SFML 2 QUIET COMPONENTS ${SFML2_FIND_COMPONENTS})
if(SFML_FOUND)
list(TRANSFORM SFML2_FIND_COMPONENTS PREPEND sfml- OUTPUT_VARIABLE SFML_LIBRARIES)
else()
list(TRANSFORM SFML_FIND_COMPONENTS PREPEND SFML:: OUTPUT_VARIABLE SFML_LIBRARIES)
find_package(SFML 3 COMPONENTS ${SFML_FIND_COMPONENTS} REQUIRED)
endif()


# Include Search Paths ---------------------------------------------------------
Expand Down Expand Up @@ -99,14 +108,11 @@ target_link_libraries(slade
${FREETYPE_LIBRARIES}
${FTGL_LIBRARIES}
${OPENGL_LIBRARIES}
${SFML_LIBRARIES}
${WX_LIBS}
${ZLIB_LIBRARY}
freeimage::FreeImage
MPG123::libmpg123
sfml-audio
sfml-main
sfml-network
sfml-window
)

if (NOT NO_LUA)
Expand Down

0 comments on commit 0604cac

Please sign in to comment.