SFML/cmake/SFMLConfigDependencies.cmake.in

90 lines
3.0 KiB
CMake
Raw Normal View History

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)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
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)
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)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(FIND_SFML_OS_ANDROID 1)
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")
set(FIND_SFML_OS_MACOS 1)
2018-03-21 02:47:29 +08:00
endif()
# When installing, save whether SFML was built using system dependencies.
set(SFML_BUILT_USING_SYSTEM_DEPS @SFML_USE_SYSTEM_DEPS@)
2018-03-21 02:47:29 +08:00
# start with an empty list
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
# Look for dependencies in "reverse order" i.e. the SFML libraries
# that depend on other SFML libraries should be placed earlier.
# This is due to the fact that among other things, resolving the
# X11 dependency will break our own find_package(Freetype CONFIG)
# because X11 attempts to find Freetype itself to resolve its Xft dependency.
# SFML::Audio
list(FIND SFML_FIND_COMPONENTS "Audio" FIND_SFML_AUDIO_COMPONENT_INDEX)
if(FIND_SFML_AUDIO_COMPONENT_INDEX GREATER -1)
if(SFML_BUILT_USING_SYSTEM_DEPS)
find_package(Vorbis)
find_package(FLAC)
else()
find_package(Vorbis CONFIG)
find_package(FLAC CONFIG)
endif()
endif()
# SFML::Graphics
list(FIND SFML_FIND_COMPONENTS "Graphics" FIND_SFML_GRAPHICS_COMPONENT_INDEX)
if(FIND_SFML_GRAPHICS_COMPONENT_INDEX GREATER -1)
if(SFML_BUILT_USING_SYSTEM_DEPS)
find_package(Freetype)
else()
find_package(Freetype CONFIG)
endif()
endif()
# 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)
if(FIND_SFML_USE_DRM)
find_dependency(DRM)
find_dependency(GBM)
elseif(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
find_dependency(X11 REQUIRED COMPONENTS Xrandr Xcursor)
2018-03-21 02:47:29 +08:00
endif()
if(FIND_SFML_OS_LINUX)
find_dependency(UDev)
2018-03-21 02:47:29 +08:00
endif()
if(NOT FIND_SFML_OS_ANDROID AND NOT FIND_SFML_OS_IOS)
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()
# SFML::System
find_dependency(Threads)
2018-03-21 02:47:29 +08:00
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 OFF)
2018-03-21 02:47:29 +08:00
endif()
endif()