2018-03-21 02:47:29 +08:00
|
|
|
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
|
|
|
|
if(SFML_STATIC_LIBRARIES)
|
2023-08-15 15:39:53 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
|
|
|
|
|
2023-02-06 08:23:57 +08:00
|
|
|
include(CMakeFindDependencyMacro)
|
|
|
|
|
2018-03-21 02:47:29 +08:00
|
|
|
# detect the OS
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
|
|
|
set(FIND_SFML_OS_WINDOWS 1)
|
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
set(FIND_SFML_OS_LINUX 1)
|
2023-02-08 15:51:52 +08:00
|
|
|
|
|
|
|
if(@SFML_USE_DRM@)
|
|
|
|
set(FIND_SFML_USE_DRM 1)
|
|
|
|
endif()
|
2018-03-21 02:47:29 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
|
|
set(FIND_SFML_OS_FREEBSD 1)
|
2023-11-15 21:36:15 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
|
|
|
set(FIND_SFML_OS_ANDROID 1)
|
2023-04-04 05:36:33 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS")
|
|
|
|
set(FIND_SFML_OS_IOS 1)
|
2018-03-21 02:47:29 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2023-02-12 12:49:05 +08:00
|
|
|
set(FIND_SFML_OS_MACOS 1)
|
2018-03-21 02:47:29 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# start with an empty list
|
|
|
|
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
|
|
|
|
2023-09-23 01:35:40 +08:00
|
|
|
# SFML::System
|
|
|
|
find_dependency(Threads)
|
|
|
|
|
2021-12-29 13:28:50 +08:00
|
|
|
# SFML::Window
|
|
|
|
list(FIND SFML_FIND_COMPONENTS "Window" FIND_SFML_WINDOW_COMPONENT_INDEX)
|
2018-03-21 02:47:29 +08:00
|
|
|
if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1)
|
2023-02-08 15:51:52 +08:00
|
|
|
if(FIND_SFML_USE_DRM)
|
2023-08-15 15:39:53 +08:00
|
|
|
find_dependency(DRM)
|
|
|
|
find_dependency(GBM)
|
2023-02-08 15:51:52 +08:00
|
|
|
elseif(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
|
2023-02-08 05:13:35 +08:00
|
|
|
find_dependency(X11 REQUIRED COMPONENTS Xrandr Xcursor)
|
2018-03-21 02:47:29 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(FIND_SFML_OS_LINUX)
|
2023-08-15 15:39:53 +08:00
|
|
|
find_dependency(UDev)
|
2018-03-21 02:47:29 +08:00
|
|
|
endif()
|
|
|
|
|
2023-11-15 21:36:15 +08:00
|
|
|
if(NOT FIND_SFML_OS_ANDROID AND NOT FIND_SFML_OS_IOS)
|
2023-08-15 15:39:53 +08:00
|
|
|
if(NOT OpenGL_GL_PREFERENCE)
|
|
|
|
set(OpenGL_GL_PREFERENCE "LEGACY")
|
|
|
|
endif()
|
|
|
|
find_dependency(OpenGL COMPONENTS OpenGL)
|
2018-03-21 02:47:29 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-12-29 13:28:50 +08:00
|
|
|
# SFML::Graphics
|
|
|
|
list(FIND SFML_FIND_COMPONENTS "Graphics" FIND_SFML_GRAPHICS_COMPONENT_INDEX)
|
2018-03-21 02:47:29 +08:00
|
|
|
if(FIND_SFML_GRAPHICS_COMPONENT_INDEX GREATER -1)
|
2023-02-08 14:38:42 +08:00
|
|
|
find_package(Freetype)
|
2018-03-21 02:47:29 +08:00
|
|
|
endif()
|
|
|
|
|
2021-12-29 13:28:50 +08:00
|
|
|
# SFML::Audio
|
|
|
|
list(FIND SFML_FIND_COMPONENTS "Audio" FIND_SFML_AUDIO_COMPONENT_INDEX)
|
2018-03-21 02:47:29 +08:00
|
|
|
if(FIND_SFML_AUDIO_COMPONENT_INDEX GREATER -1)
|
2023-08-27 06:24:50 +08:00
|
|
|
find_package(Vorbis)
|
2023-08-27 03:30:05 +08:00
|
|
|
find_package(FLAC)
|
2018-03-21 02:47:29 +08:00
|
|
|
endif()
|
|
|
|
|
2022-10-07 01:33:19 +08:00
|
|
|
if(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
2018-03-21 02:47:29 +08:00
|
|
|
set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
|
|
|
|
set(SFML_FOUND FALSE)
|
|
|
|
endif()
|
|
|
|
endif()
|