2016-05-19 14:41:06 +00:00
|
|
|
#
|
|
|
|
# Build configuration
|
|
|
|
#
|
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
|
2016-05-24 13:10:30 +00:00
|
|
|
# TODO(jaagr): Replace with git tag
|
2016-06-14 11:17:26 +00:00
|
|
|
project(lemonbuddy VERSION 1.2.0)
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_MODULE_PATH}"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Wpedantic -Wno-unused-parameter")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -DDEBUG")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
|
|
|
|
2016-05-20 02:27:24 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
message(STATUS "No build type specified; using Release")
|
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
|
|
endif()
|
|
|
|
|
2016-05-24 12:24:45 +00:00
|
|
|
string(ASCII 27 ANSI)
|
|
|
|
|
2016-05-19 14:41:06 +00:00
|
|
|
#
|
|
|
|
# Internal values and switches
|
|
|
|
#
|
2016-05-24 02:06:29 +00:00
|
|
|
option(ENABLE_CCACHE "Enable ccache support" ON)
|
|
|
|
option(ENABLE_ALSA "Enable alsa support" ON)
|
|
|
|
option(ENABLE_I3 "Enable i3 support" ON)
|
|
|
|
option(ENABLE_MPD "Enable mpd support" ON)
|
|
|
|
option(ENABLE_NETWORK "Enable network support" ON)
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
if(ENABLE_ALSA)
|
|
|
|
set(SETTING_ALSA_SOUNDCARD "default"
|
|
|
|
CACHE STRING "Name of the ALSA soundcard driver")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(SETTING_CONNECTION_TEST_IP "8.8.8.8"
|
|
|
|
CACHE STRING "Address to ping when testing network connection")
|
|
|
|
set(SETTING_PATH_BACKLIGHT_VAL "/sys/class/backlight/%card%/brightness"
|
|
|
|
CACHE STRING "Path to file containing the current backlight value")
|
|
|
|
set(SETTING_PATH_BACKLIGHT_MAX "/sys/class/backlight/%card%/max_brightness"
|
|
|
|
CACHE STRING "Path to file containing the maximum backlight value")
|
|
|
|
set(SETTING_PATH_BATTERY_CAPACITY "/sys/class/power_supply/%battery%/capacity"
|
|
|
|
CACHE STRING "Path to file containing the current battery capacity")
|
|
|
|
set(SETTING_PATH_ADAPTER_STATUS "/sys/class/power_supply/%adapter%/online"
|
|
|
|
CACHE STRING "Path to file containing the current adapter status")
|
|
|
|
set(SETTING_BSPWM_SOCKET_PATH "/tmp/bspwm_0_0-socket"
|
|
|
|
CACHE STRING "Path to bspwm socket")
|
|
|
|
set(SETTING_BSPWM_STATUS_PREFIX "W"
|
|
|
|
CACHE STRING "Prefix prepended to the bspwm status line")
|
|
|
|
set(SETTING_PATH_CPU_INFO "/proc/stat"
|
|
|
|
CACHE STRING "Path to file containing cpu info")
|
|
|
|
set(SETTING_PATH_MEMORY_INFO "/proc/meminfo"
|
|
|
|
CACHE STRING "Path to file containing memory info")
|
|
|
|
|
|
|
|
if(ENABLE_CCACHE)
|
|
|
|
find_program(CCACHE_FOUND "ccache")
|
|
|
|
if(CCACHE_FOUND)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache")
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Locate and insert libs
|
|
|
|
#
|
|
|
|
find_package("Boost" REQUIRED)
|
|
|
|
find_package("Threads" REQUIRED)
|
2016-05-24 12:24:45 +00:00
|
|
|
find_package("X11" REQUIRED "X11_Xrandr")
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-24 12:24:45 +00:00
|
|
|
set(PROJECT_INCL_DIRS "${PROJECT_SOURCE_DIR}/include"
|
2016-05-19 14:41:06 +00:00
|
|
|
${Boost_INCLUDE_DIRS}
|
2016-05-24 12:24:45 +00:00
|
|
|
${X11_INCLUDE_DIR})
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-24 12:24:45 +00:00
|
|
|
set(PROJECT_LINK_LIBS
|
2016-05-19 14:41:06 +00:00
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${X11_LIBRARIES}
|
|
|
|
${X11_Xrandr_LIB}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
2016-05-24 12:24:45 +00:00
|
|
|
if(ENABLE_I3)
|
|
|
|
find_program(I3_EXECUTABLE "i3")
|
|
|
|
if(NOT I3_EXECUTABLE)
|
2016-05-31 03:58:58 +00:00
|
|
|
message(WARNING "${ANSI}[41;1mDisabling \"i3 module\" support (prerequisites failed)${ANSI}[0m")
|
2016-05-24 12:24:45 +00:00
|
|
|
set(ENABLE_I3 OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-05-19 14:41:06 +00:00
|
|
|
if(ENABLE_ALSA)
|
2016-05-20 09:20:58 +00:00
|
|
|
find_package("ALSA")
|
|
|
|
if(ALSA_FOUND)
|
2016-05-24 12:24:45 +00:00
|
|
|
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${ALSA_INCLUDE_DIR})
|
|
|
|
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${ALSA_LIBRARY})
|
2016-05-20 09:20:58 +00:00
|
|
|
else(ALSA_FOUND)
|
2016-05-31 03:58:58 +00:00
|
|
|
message(WARNING "${ANSI}[41;1mDisabling \"volume module\" support (prerequisites failed)${ANSI}[0m")
|
2016-05-24 02:06:29 +00:00
|
|
|
set(ENABLE_ALSA OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-05-19 14:41:06 +00:00
|
|
|
if(ENABLE_MPD)
|
2016-05-20 09:20:58 +00:00
|
|
|
find_package("LibMPDClient")
|
2016-05-24 02:24:59 +00:00
|
|
|
if(LIBMPDCLIENT_FOUND)
|
2016-05-24 12:24:45 +00:00
|
|
|
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${LIBMPDCLIENT_INCLUDE_DIR})
|
|
|
|
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${LIBMPDCLIENT_LIBRARY})
|
2016-05-24 02:24:59 +00:00
|
|
|
else(LIBMPDCLIENT_FOUND)
|
2016-05-31 03:58:58 +00:00
|
|
|
message(WARNING "${ANSI}[41;1mDisabling \"mpd module\" support (prerequisites failed)${ANSI}[0m")
|
2016-05-20 09:20:58 +00:00
|
|
|
set(ENABLE_MPD OFF)
|
|
|
|
endif()
|
2016-05-19 14:41:06 +00:00
|
|
|
endif()
|
|
|
|
|
2016-05-24 02:06:29 +00:00
|
|
|
if(ENABLE_NETWORK)
|
|
|
|
find_package("Libiw")
|
2016-05-24 02:24:59 +00:00
|
|
|
if(LIBIW_FOUND)
|
2016-05-24 12:24:45 +00:00
|
|
|
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${LIBIW_INCLUDE_DIR})
|
|
|
|
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${LIBIW_LIBRARY})
|
2016-05-24 02:24:59 +00:00
|
|
|
else(LIBIW_FOUND)
|
2016-05-31 03:58:58 +00:00
|
|
|
message(WARNING "${ANSI}[41;1mDisabling \"network module\" support (prerequisites failed)${ANSI}[0m")
|
2016-05-24 02:06:29 +00:00
|
|
|
set(ENABLE_NETWORK OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-05-20 09:20:58 +00:00
|
|
|
|
2016-05-19 14:41:06 +00:00
|
|
|
#
|
|
|
|
# Install executable and wrapper
|
|
|
|
#
|
2016-05-24 02:06:29 +00:00
|
|
|
message(STATUS "---------------------------")
|
|
|
|
message(STATUS " Enable ccache support ${ENABLE_CCACHE}")
|
|
|
|
message(STATUS " Enable alsa support ${ENABLE_ALSA}")
|
|
|
|
message(STATUS " Enable i3 support ${ENABLE_I3}")
|
|
|
|
message(STATUS " Enable mpd support ${ENABLE_MPD}")
|
|
|
|
message(STATUS " Enable network support ${ENABLE_NETWORK}")
|
|
|
|
message(STATUS "---------------------------")
|
|
|
|
|
2016-05-19 14:41:06 +00:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/src")
|
2016-05-24 12:41:36 +00:00
|
|
|
add_executable(${PROJECT_NAME} ${SOURCE_FILES}
|
|
|
|
"examples/config"
|
|
|
|
"examples/config.bspwm"
|
|
|
|
"examples/config.i3")
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
if(ENABLE_I3)
|
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/contrib/i3ipcpp" EXCLUDE_FROM_ALL)
|
2016-05-24 12:24:45 +00:00
|
|
|
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS}
|
|
|
|
${SIGCPP_INCLUDE_DIRS}
|
|
|
|
${I3IPCpp_INCLUDE_DIRS})
|
|
|
|
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${I3IPCpp_LIBRARIES})
|
2016-05-19 14:41:06 +00:00
|
|
|
endif()
|
|
|
|
|
2016-05-24 12:24:45 +00:00
|
|
|
include_directories(${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_INCL_DIRS})
|
|
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} ${PROJECT_LINK_LIBS})
|
|
|
|
|
2016-05-20 09:20:58 +00:00
|
|
|
configure_file("${CMAKE_SOURCE_DIR}/include/config.hpp.cmake" "${CMAKE_SOURCE_DIR}/include/config.hpp" ESCAPE_QUOTES @ONLY)
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-24 12:41:36 +00:00
|
|
|
install(TARGETS ${PROJECT_NAME}
|
|
|
|
DESTINATION "bin"
|
|
|
|
COMPONENT "binaries")
|
2016-06-11 05:44:46 +00:00
|
|
|
install(PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/lemonbuddy_wrapper"
|
|
|
|
DESTINATION "bin" COMPONENT "binaries")
|
|
|
|
install(PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/lemonbuddy_terminate"
|
|
|
|
DESTINATION "bin" COMPONENT "binaries")
|
2016-05-24 12:41:36 +00:00
|
|
|
|
|
|
|
install(FILES "examples/config"
|
|
|
|
DESTINATION "share/examples/${PROJECT_NAME}"
|
|
|
|
COMPONENT "config")
|
|
|
|
install(FILES "examples/config.bspwm"
|
|
|
|
DESTINATION "share/examples/${PROJECT_NAME}"
|
|
|
|
COMPONENT "config")
|
|
|
|
install(FILES "examples/config.i3"
|
|
|
|
DESTINATION "share/examples/${PROJECT_NAME}"
|
|
|
|
COMPONENT "config")
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Uninstall target
|
|
|
|
#
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND}
|
|
|
|
-P "${CMAKE_CURRENT_BINARY_DIR}/cmake/uninstall.cmake")
|