diff --git a/CMakeLists.txt b/CMakeLists.txt index 91f7a6e061..dfbc6796b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -364,7 +364,6 @@ endif() include_directories(${XKB_INCLUDE_DIR}) -include_directories(${epoxy_INCLUDE_DIR}) set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX}) # for things that are also used by kwin libraries @@ -707,7 +706,7 @@ set_target_properties(kwin PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} ) -target_link_libraries(kwin ${kwinLibs} kwinglutils ${epoxy_LIBRARY}) +target_link_libraries(kwin ${kwinLibs} kwinglutils epoxy::epoxy) if (KWIN_BUILD_CMS) target_sources(kwin PRIVATE diff --git a/cmake/modules/Findepoxy.cmake b/cmake/modules/Findepoxy.cmake index d137f33051..548be5bc35 100644 --- a/cmake/modules/Findepoxy.cmake +++ b/cmake/modules/Findepoxy.cmake @@ -1,34 +1,83 @@ -# - Try to find libepoxy -# Once done this will define +#.rst: +# Findepoxy +# --------- # -# epoxy_FOUND - System has libepoxy -# epoxy_LIBRARY - The libepoxy library -# epoxy_INCLUDE_DIR - The libepoxy include dir -# epoxy_DEFINITIONS - Compiler switches required for using libepoxy -# epoxy_HAS_GLX - Whether GLX support is available +# Try to find libepoxy on a Unix system. +# +# This will define the following variables: +# +# ``epoxy_FOUND`` +# True if (the requested version of) libepoxy is available +# ``epoxy_VERSION`` +# The version of libepoxy +# ``epoxy_LIBRARIES`` +# This should be passed to target_link_libraries() if the target is not +# used for linking +# ``epoxy_INCLUDE_DIRS`` +# This should be passed to target_include_directories() if the target is not +# used for linking +# ``epoxy_DEFINITIONS`` +# This should be passed to target_compile_options() if the target is not +# used for linking +# ``epoxy_HAS_GLX`` +# True if GLX support is available +# +# If ``epoxy_FOUND`` is TRUE, it will also define the following imported target: +# +# ``epoxy::epoxy`` +# The epoxy library +# +# In general we recommend using the imported target, as it is easier to use. +# Bear in mind, however, that if the target is in the link interface of an +# exported library, it must be made available by the package config file. # SPDX-FileCopyrightText: 2014 Fredrik Höglund +# SPDX-FileCopyrightText: 2020 Vlad Zahorodnii # # SPDX-License-Identifier: BSD-3-Clause -if (NOT WIN32) - find_package(PkgConfig) - pkg_check_modules(PKG_epoxy QUIET epoxy) +find_package(PkgConfig) +pkg_check_modules(PKG_epoxy QUIET epoxy) - set(epoxy_DEFINITIONS ${PKG_epoxy_CFLAGS}) +set(epoxy_VERSION ${PKG_epoxy_VERSION}) +set(epoxy_DEFINITIONS ${PKG_epoxy_CFLAGS}) - find_path(epoxy_INCLUDE_DIR NAMES epoxy/gl.h HINTS ${PKG_epoxy_INCLUDEDIR} ${PKG_epoxy_INCLUDE_DIRS}) - find_library(epoxy_LIBRARY NAMES epoxy HINTS ${PKG_epoxy_LIBDIR} ${PKG_epoxy_LIBRARY_DIRS}) - find_file(epoxy_GLX_HEADER NAMES epoxy/glx.h HINTS ${epoxy_INCLUDE_DIR}) +find_path(epoxy_INCLUDE_DIRS + NAMES epoxy/gl.h + HINTS ${PKG_epoxy_INCLUDEDIR} ${PKG_epoxy_INCLUDE_DIRS} +) +find_library(epoxy_LIBRARIES + NAMES epoxy + HINTS ${PKG_epoxy_LIBDIR} ${PKG_epoxy_LIBRARY_DIRS} +) +find_file(epoxy_GLX_HEADER NAMES epoxy/glx.h HINTS ${epoxy_INCLUDE_DIR}) - if (epoxy_GLX_HEADER STREQUAL "epoxy_GLX_HEADER-NOTFOUND") +if (epoxy_GLX_HEADER STREQUAL "epoxy_GLX_HEADER-NOTFOUND") set(epoxy_HAS_GLX FALSE CACHE BOOL "whether glx is available") - else () +else () set(epoxy_HAS_GLX TRUE CACHE BOOL "whether glx is available") - endif() +endif() - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(epoxy DEFAULT_MSG epoxy_LIBRARY epoxy_INCLUDE_DIR) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(epoxy + FOUND_VAR epoxy_FOUND + REQUIRED_VARS epoxy_LIBRARIES epoxy_INCLUDE_DIRS + VERSION_VAR epoxy_VERSION +) - mark_as_advanced(epoxy_INCLUDE_DIR epoxy_LIBRARY epoxy_HAS_GLX) +if (epoxy_FOUND AND NOT TARGET epoxy::epoxy) + add_library(epoxy::epoxy UNKNOWN IMPORTED) + set_target_properties(epoxy::epoxy PROPERTIES + IMPORTED_LOCATION "${epoxy_LIBRARIES}" + INTERFACE_COMPILE_OPTIONS "${epoxy_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${epoxy_INCLUDE_DIRS}" + ) endif() + +mark_as_advanced( + epoxy_DEFINITIONS + epoxy_HAS_GLX + epoxy_INCLUDE_DIRS + epoxy_LIBRARIES + epoxy_VERSION +) diff --git a/libkwineffects/CMakeLists.txt b/libkwineffects/CMakeLists.txt index f30dcc910a..5481cdd910 100644 --- a/libkwineffects/CMakeLists.txt +++ b/libkwineffects/CMakeLists.txt @@ -80,8 +80,7 @@ set(kwin_GLUTILSLIB_SRCS add_library(kwinglutils SHARED ${kwin_GLUTILSLIB_SRCS}) generate_export_header(kwinglutils BASE_NAME kwinglutils EXPORT_FILE_NAME kwinglutils_export.h) -target_include_directories(kwinglutils PUBLIC ${epoxy_INCLUDE_DIR}) -target_link_libraries(kwinglutils PUBLIC XCB::XCB KF5::CoreAddons KF5::ConfigCore KF5::WindowSystem ${epoxy_LIBRARY}) +target_link_libraries(kwinglutils PUBLIC XCB::XCB KF5::CoreAddons KF5::ConfigCore KF5::WindowSystem epoxy::epoxy) set_target_properties(kwinglutils PROPERTIES VERSION ${KWINEFFECTS_VERSION_STRING} SOVERSION ${KWINEFFECTS_SOVERSION}