mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Prefer using IMPORTED
targets where possible
My goal is to reduce our need on sfml_find_package until it can finally be removed. It's preferred to simply use find_package to find 3rd party projects. I had to add IMPORTED targets to some of our find modules so that we could get away from using INTERFACE libraries for external code. That also implied that our find moduels need to be installed so that users have access to them when processing SFML's config module.
This commit is contained in:
parent
af7d6c2589
commit
f0e72be285
@ -259,6 +259,9 @@ if(NOT SFML_BUILD_FRAMEWORKS)
|
|||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
COMPONENT devel
|
COMPONENT devel
|
||||||
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl")
|
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl")
|
||||||
|
install(DIRECTORY cmake/Modules/
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SFML
|
||||||
|
COMPONENT devel)
|
||||||
|
|
||||||
if(SFML_GENERATE_PDB)
|
if(SFML_GENERATE_PDB)
|
||||||
install(DIRECTORY ${PROJECT_BINARY_DIR}/lib/
|
install(DIRECTORY ${PROJECT_BINARY_DIR}/lib/
|
||||||
|
@ -16,3 +16,8 @@ find_library(DRM_LIBRARY NAMES drm)
|
|||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(DRM DEFAULT_MSG DRM_LIBRARY DRM_INCLUDE_DIR)
|
find_package_handle_standard_args(DRM DEFAULT_MSG DRM_LIBRARY DRM_INCLUDE_DIR)
|
||||||
|
|
||||||
|
add_library(DRM::DRM IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(DRM::DRM PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${DRM_INCLUDE_DIR}/libdrm
|
||||||
|
IMPORTED_LOCATION ${DRM_LIBRARY})
|
||||||
|
@ -12,3 +12,8 @@ find_library(EGL_LIBRARY NAMES EGL)
|
|||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
|
find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
|
||||||
|
|
||||||
|
add_library(EGL::EGL IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(EGL::EGL PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${EGL_INCLUDE_DIR}
|
||||||
|
IMPORTED_LOCATION ${EGL_LIBRARY})
|
||||||
|
@ -16,3 +16,8 @@ find_library(GBM_LIBRARY NAMES gbm)
|
|||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(GBM DEFAULT_MSG GBM_LIBRARY GBM_INCLUDE_DIR)
|
find_package_handle_standard_args(GBM DEFAULT_MSG GBM_LIBRARY GBM_INCLUDE_DIR)
|
||||||
|
|
||||||
|
add_library(GBM::GBM IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(GBM::GBM PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${GBM_INCLUDE_DIR}
|
||||||
|
IMPORTED_LOCATION ${GBM_LIBRARY})
|
||||||
|
@ -12,3 +12,8 @@ find_library(GLES_LIBRARY NAMES GLESv1_CM)
|
|||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(GLES DEFAULT_MSG GLES_LIBRARY GLES_INCLUDE_DIR)
|
find_package_handle_standard_args(GLES DEFAULT_MSG GLES_LIBRARY GLES_INCLUDE_DIR)
|
||||||
|
|
||||||
|
add_library(GLES::GLES IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(GLES::GLES PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${GLES_INCLUDE_DIR}
|
||||||
|
IMPORTED_LOCATION ${GLES_LIBRARY})
|
||||||
|
@ -50,4 +50,12 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(UDev DEFAULT_MSG UDEV_INCLUDE_DIR UDEV_LIBRARIES)
|
||||||
|
|
||||||
mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBRARIES)
|
mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBRARIES)
|
||||||
|
|
||||||
|
add_library(UDev::UDev IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(UDev::UDev PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${UDEV_INCLUDE_DIR}
|
||||||
|
IMPORTED_LOCATION ${UDEV_LIBRARIES})
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
|
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
|
||||||
if(SFML_STATIC_LIBRARIES)
|
if(SFML_STATIC_LIBRARIES)
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
include(CMakeFindDependencyMacro)
|
include(CMakeFindDependencyMacro)
|
||||||
|
|
||||||
# detect the OS
|
# detect the OS
|
||||||
@ -44,20 +46,21 @@ if(SFML_STATIC_LIBRARIES)
|
|||||||
list(FIND SFML_FIND_COMPONENTS "Window" FIND_SFML_WINDOW_COMPONENT_INDEX)
|
list(FIND SFML_FIND_COMPONENTS "Window" FIND_SFML_WINDOW_COMPONENT_INDEX)
|
||||||
if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1)
|
if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1)
|
||||||
if(FIND_SFML_USE_DRM)
|
if(FIND_SFML_USE_DRM)
|
||||||
sfml_bind_dependency(TARGET DRM FRIENDLY_NAME "drm" SEARCH_NAMES "drm")
|
find_dependency(DRM)
|
||||||
sfml_bind_dependency(TARGET GBM FRIENDLY_NAME "gbm" SEARCH_NAMES "gbm")
|
find_dependency(GBM)
|
||||||
elseif(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
|
elseif(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
|
||||||
find_dependency(X11 REQUIRED COMPONENTS Xrandr Xcursor)
|
find_dependency(X11 REQUIRED COMPONENTS Xrandr Xcursor)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FIND_SFML_OS_LINUX)
|
if(FIND_SFML_OS_LINUX)
|
||||||
sfml_bind_dependency(TARGET UDev FRIENDLY_NAME "UDev" SEARCH_NAMES "udev" "libudev")
|
find_dependency(UDev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FIND_SFML_OS_WINDOWS)
|
if(NOT FIND_SFML_OS_IOS)
|
||||||
set_property(TARGET OpenGL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "OpenGL32")
|
if(NOT OpenGL_GL_PREFERENCE)
|
||||||
elseif(NOT FIND_SFML_OS_IOS)
|
set(OpenGL_GL_PREFERENCE "LEGACY")
|
||||||
sfml_bind_dependency(TARGET OpenGL FRIENDLY_NAME "OpenGL" SEARCH_NAMES "OpenGL" "GL")
|
endif()
|
||||||
|
find_dependency(OpenGL COMPONENTS OpenGL)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -278,10 +278,9 @@ sfml_add_library(Window
|
|||||||
# DRM libraries
|
# DRM libraries
|
||||||
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
|
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
|
||||||
if(SFML_USE_DRM)
|
if(SFML_USE_DRM)
|
||||||
sfml_find_package(DRM DRM_INCLUDE_DIR DRM_LIBRARY)
|
find_package(DRM REQUIRED)
|
||||||
target_include_directories(sfml-window PRIVATE ${DRM_INCLUDE_DIR}/libdrm)
|
find_package(GBM REQUIRED)
|
||||||
sfml_find_package(GBM GBM_INCLUDE_DIR GBM_LIBRARY)
|
target_link_libraries(sfml-window PRIVATE DRM::DRM GBM::GBM EGL)
|
||||||
target_link_libraries(sfml-window PRIVATE drm gbm EGL)
|
|
||||||
else()
|
else()
|
||||||
find_package(X11 REQUIRED COMPONENTS Xrandr Xcursor)
|
find_package(X11 REQUIRED COMPONENTS Xrandr Xcursor)
|
||||||
target_link_libraries(sfml-window PRIVATE X11::X11 X11::Xrandr X11::Xcursor)
|
target_link_libraries(sfml-window PRIVATE X11::X11 X11::Xrandr X11::Xcursor)
|
||||||
@ -311,13 +310,12 @@ endif()
|
|||||||
if(SFML_OS_IOS)
|
if(SFML_OS_IOS)
|
||||||
target_link_libraries(sfml-window PRIVATE "-framework OpenGLES")
|
target_link_libraries(sfml-window PRIVATE "-framework OpenGLES")
|
||||||
elseif(SFML_OS_ANDROID)
|
elseif(SFML_OS_ANDROID)
|
||||||
sfml_find_package(GLES GLES_INCLUDE_DIR GLES_LIBRARY)
|
find_package(EGL REQUIRED)
|
||||||
sfml_find_package(EGL EGL_INCLUDE_DIR EGL_LIBRARY)
|
find_package(GLES REQUIRED)
|
||||||
target_link_libraries(sfml-window PRIVATE EGL)
|
target_link_libraries(sfml-window PRIVATE EGL::EGL GLES::GLES)
|
||||||
target_link_libraries(sfml-window PRIVATE GLES)
|
|
||||||
else()
|
else()
|
||||||
sfml_find_package(OpenGL OPENGL_INCLUDE_DIR OPENGL_gl_LIBRARY)
|
find_package(OpenGL REQUIRED COMPONENTS OpenGL)
|
||||||
target_link_libraries(sfml-window PRIVATE OpenGL)
|
target_link_libraries(sfml-window PRIVATE OpenGL::GL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
|
if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
|
||||||
@ -329,8 +327,8 @@ if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SFML_OS_LINUX)
|
if(SFML_OS_LINUX)
|
||||||
sfml_find_package(UDev UDEV_INCLUDE_DIR UDEV_LIBRARIES)
|
find_package(UDev REQUIRED)
|
||||||
target_link_libraries(sfml-window PRIVATE UDev dl)
|
target_link_libraries(sfml-window PRIVATE UDev::UDev dl)
|
||||||
elseif(SFML_OS_WINDOWS)
|
elseif(SFML_OS_WINDOWS)
|
||||||
target_link_libraries(sfml-window PRIVATE winmm gdi32)
|
target_link_libraries(sfml-window PRIVATE winmm gdi32)
|
||||||
elseif(SFML_OS_FREEBSD)
|
elseif(SFML_OS_FREEBSD)
|
||||||
|
Loading…
Reference in New Issue
Block a user