Skip to content

Commit 1ebb66b

Browse files
committed
Fix compilation on FreeBSD
1 parent bfa8a2a commit 1ebb66b

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ set(CMAKE_AUTOUIC ON)
1717

1818
set(CMAKE_INCLUDE_CURRENT_DIR ON)
1919

20+
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
21+
2022
find_package(Qt5Widgets REQUIRED)
2123
find_package(Qt5DBus REQUIRED)
2224
find_package(KF5WindowSystem REQUIRED)
2325
find_package(Qt5X11Extras REQUIRED)
26+
find_package(XCB REQUIRED COMPONENTS xcb)
2427

2528
set(SRCS main.cpp
2629
menuimporter.h menuimporter.cpp
@@ -57,5 +60,5 @@ target_link_libraries(${PROJECT}
5760
Qt5::DBus
5861
Qt5::X11Extras
5962
KF5::WindowSystem
60-
xcb
61-
)
63+
${XCB_LIBRARIES}
64+
)

cmake/FindXCB.cmake

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#.rst:
2+
# FindXCB
3+
# -------
4+
#
5+
# Find XCB libraries
6+
#
7+
# Tries to find xcb libraries on unix systems.
8+
#
9+
# - Be sure to set the COMPONENTS to the components you want to link to
10+
# - The XCB_LIBRARIES variable is set ONLY to your COMPONENTS list
11+
# - To use only a specific component check the XCB_LIBRARIES_${COMPONENT} variable
12+
#
13+
# The following values are defined
14+
#
15+
# ::
16+
#
17+
# XCB_FOUND - True if xcb is available
18+
# XCB_INCLUDE_DIRS - Include directories for xcb
19+
# XCB_LIBRARIES - List of libraries for xcb
20+
# XCB_DEFINITIONS - List of definitions for xcb
21+
#
22+
#=============================================================================
23+
# Copyright (c) 2015 Jari Vetoniemi
24+
#
25+
# Distributed under the OSI-approved BSD License (the "License");
26+
#
27+
# This software is distributed WITHOUT ANY WARRANTY; without even the
28+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
29+
# See the License for more information.
30+
#=============================================================================
31+
32+
include(FeatureSummary)
33+
set_package_properties(XCB PROPERTIES
34+
URL "https://xcb.freedesktop.org/"
35+
DESCRIPTION "X protocol C-language Binding")
36+
37+
find_package(PkgConfig)
38+
pkg_check_modules(PC_XCB xcb ${XCB_FIND_COMPONENTS})
39+
40+
find_library(XCB_LIBRARIES xcb HINTS ${PC_XCB_LIBRARY_DIRS})
41+
find_path(XCB_INCLUDE_DIRS xcb/xcb.h PATH_SUFFIXES xcb HINTS ${PC_XCB_INCLUDE_DIRS})
42+
43+
foreach(COMPONENT ${XCB_FIND_COMPONENTS})
44+
find_library(XCB_LIBRARIES_${COMPONENT} ${COMPONENT} HINTS ${PC_XCB_LIBRARY_DIRS})
45+
list(APPEND XCB_LIBRARIES ${XCB_LIBRARIES_${COMPONENT}})
46+
mark_as_advanced(XCB_LIBRARIES_${COMPONENT})
47+
endforeach(COMPONENT ${XCB_FIND_COMPONENTS})
48+
49+
set(XCB_DEFINITIONS ${PC_XCB_CFLAGS_OTHER})
50+
51+
include(FindPackageHandleStandardArgs)
52+
find_package_handle_standard_args(XCB DEFAULT_MSG XCB_LIBRARIES XCB_INCLUDE_DIRS)
53+
mark_as_advanced(XCB_INCLUDE_DIRS XCB_LIBRARIES XCB_DEFINITIONS)

0 commit comments

Comments
 (0)