Skip to content

Commit

Permalink
Add options for renderers, make deps required
Browse files Browse the repository at this point in the history
  • Loading branch information
danyspin97 committed Mar 25, 2019
1 parent 33e540a commit 5ca3262
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 36 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ SET(BEMENU_DESCRIPTION "Dynamic menu library and client program inspired by dmen
SET(BEMENU_VERSION "0.1.0")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)

OPTION(BEMENU_CURSES_RENDERER "Build curses backend" ON)
OPTION(BEMENU_X11_RENDERER "Build X11 backend" ON)
OPTION(BEMENU_WAYLAND_RENDERER "Build wayland renderer" OFF)

INCLUDE(CTest)
INCLUDE(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ bemenu

Dynamic menu library and client program inspired by dmenu

## Renderers

bemenu supports three different renderers:

- ncurses
- X11
- Wayland

Enable/disable the renderers by appending these CMake options when executing `cmake <dir>`:

- `-DBEMENU_CURSES_RENDERER=[OFF|ON]`
- `-DBEMENU_X11_RENDERER=[OFF|ON]`
- `-DBEMENU_WAYLAND_RENDERER=[OFF|ON]`

## License
* [GNU GPLv3 (or any later version)](LICENSE-CLIENT) for client program[s] and
other sources except library and bindings
Expand Down
22 changes: 17 additions & 5 deletions lib/renderers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
SET(RENDERERS
"curses"
"wayland"
"x11"
)
SET(RENDERERS "")

IF(BEMENU_CURSES_RENDERER)
LIST(APPEND RENDERERS "curses")
ENDIF()

IF(BEMENU_X11_RENDERER)
LIST(APPEND RENDERERS "x11")
ENDIF()

IF(BEMENU_WAYLAND_RENDERER)
LIST(APPEND RENDERERS "wayland")
ENDIF()

IF(NOT RENDERERS)
MESSAGE(FATAL_ERROR "At least one renderer should be enabled")
ENDIF()

ADD_DEFINITIONS(-DPANGO_DISABLE_DEPRECATED)

Expand Down
14 changes: 6 additions & 8 deletions lib/renderers/curses/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
SET(CURSES_NEED_NCURSES TRUE)
FIND_PACKAGE(Curses)
FIND_PACKAGE(Curses REQUIRED)

if (CURSES_FOUND)
INCLUDE_DIRECTORIES(${CURSES_INCLUDE_DIRS})
ADD_LIBRARY(bemenu-renderer-curses SHARED curses.c)
SET_TARGET_PROPERTIES(bemenu-renderer-curses PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(bemenu-renderer-curses ${BEMENU_LIBRARIES} ${CURSES_LIBRARY} m)
INSTALL(TARGETS bemenu-renderer-curses DESTINATION "${CMAKE_INSTALL_LIBDIR}/bemenu")
endif ()
INCLUDE_DIRECTORIES(${CURSES_INCLUDE_DIRS})
ADD_LIBRARY(bemenu-renderer-curses SHARED curses.c)
SET_TARGET_PROPERTIES(bemenu-renderer-curses PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(bemenu-renderer-curses ${BEMENU_LIBRARIES} ${CURSES_LIBRARY} m)
INSTALL(TARGETS bemenu-renderer-curses DESTINATION "${CMAKE_INSTALL_LIBDIR}/bemenu")
26 changes: 12 additions & 14 deletions lib/renderers/wayland/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
FIND_PACKAGE(Wayland)
FIND_PACKAGE(Cairo)
FIND_PACKAGE(Pango)
FIND_PACKAGE(XKBCommon)
FIND_PACKAGE(Wayland REQUIRED)
FIND_PACKAGE(Cairo REQUIRED)
FIND_PACKAGE(Pango REQUIRED)
FIND_PACKAGE(XKBCommon REQUIRED)

if (WAYLAND_FOUND AND CAIRO_FOUND AND PANGO_FOUND AND XKBCOMMON_FOUND)
INCLUDE(Wayland)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-layer-shell "wlr-layer-shell-unstable-v1.xml" layer-shell)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-xdg-shell "xdg-shell.xml" xdg-shell)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${WAYLAND_CLIENT_INCLUDE_DIR} ${XKBCOMMON_INCLUDE_DIR} ${CAIRO_INCLUDE_DIRS} ${PANGO_INCLUDE_DIRS})
ADD_LIBRARY(bemenu-renderer-wayland SHARED wayland.c registry.c window.c ${proto-layer-shell} ${proto-xdg-shell})
SET_TARGET_PROPERTIES(bemenu-renderer-wayland PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(bemenu-renderer-wayland ${BEMENU_LIBRARIES} ${WAYLAND_CLIENT_LIBRARIES} ${XKBCOMMON_LIBRARIES} ${CAIRO_LIBRARIES} ${PANGO_LIBRARIES} m)
INSTALL(TARGETS bemenu-renderer-wayland DESTINATION "${CMAKE_INSTALL_LIBDIR}/bemenu")
endif ()
INCLUDE(Wayland)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-layer-shell "wlr-layer-shell-unstable-v1.xml" layer-shell)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-xdg-shell "xdg-shell.xml" xdg-shell)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${WAYLAND_CLIENT_INCLUDE_DIR} ${XKBCOMMON_INCLUDE_DIR} ${CAIRO_INCLUDE_DIRS} ${PANGO_INCLUDE_DIRS})
ADD_LIBRARY(bemenu-renderer-wayland SHARED wayland.c registry.c window.c ${proto-layer-shell} ${proto-xdg-shell})
SET_TARGET_PROPERTIES(bemenu-renderer-wayland PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(bemenu-renderer-wayland ${BEMENU_LIBRARIES} ${WAYLAND_CLIENT_LIBRARIES} ${XKBCOMMON_LIBRARIES} ${CAIRO_LIBRARIES} ${PANGO_LIBRARIES} m)
INSTALL(TARGETS bemenu-renderer-wayland DESTINATION "${CMAKE_INSTALL_LIBDIR}/bemenu")
16 changes: 7 additions & 9 deletions lib/renderers/x11/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
FIND_PACKAGE(X11)
FIND_PACKAGE(Cairo)
FIND_PACKAGE(X11 REQUIRED)
FIND_PACKAGE(Cairo REQUIRED)

if (X11_FOUND AND X11_Xinerama_FOUND AND CAIRO_FOUND AND PANGO_FOUND)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${X11_INCLUDE_DIR} ${X11_Xinerama_INCLUDE_PATH} ${CAIRO_INCLUDE_DIRS} ${PANGO_INCLUDE_DIRS})
ADD_LIBRARY(bemenu-renderer-x11 SHARED x11.c window.c xkb_unicode.c)
SET_TARGET_PROPERTIES(bemenu-renderer-x11 PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(bemenu-renderer-x11 ${BEMENU_LIBRARIES} ${X11_LIBRARIES} ${X11_Xinerama_LIB} ${CAIRO_LIBRARIES} ${PANGO_LIBRARIES} m)
INSTALL(TARGETS bemenu-renderer-x11 DESTINATION "${CMAKE_INSTALL_LIBDIR}/bemenu")
endif ()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${X11_INCLUDE_DIR} ${X11_Xinerama_INCLUDE_PATH} ${CAIRO_INCLUDE_DIRS} ${PANGO_INCLUDE_DIRS})
ADD_LIBRARY(bemenu-renderer-x11 SHARED x11.c window.c xkb_unicode.c)
SET_TARGET_PROPERTIES(bemenu-renderer-x11 PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(bemenu-renderer-x11 ${BEMENU_LIBRARIES} ${X11_LIBRARIES} ${X11_Xinerama_LIB} ${CAIRO_LIBRARIES} ${PANGO_LIBRARIES} m)
INSTALL(TARGETS bemenu-renderer-x11 DESTINATION "${CMAKE_INSTALL_LIBDIR}/bemenu")

0 comments on commit 5ca3262

Please sign in to comment.