mirror of
https://github.com/polybar/polybar.git
synced 2024-12-02 14:05:27 -05:00
refactor(cmake): Removed dynamic handling of flags
Only set initial state of the ENABLE_X options based on if the required library is available
This commit is contained in:
parent
b8a8528e84
commit
2b1aa99f4c
1 changed files with 39 additions and 58 deletions
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# Build configuration
|
# Build configuration
|
||||||
#
|
#
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
|
||||||
project(lemonbuddy C CXX)
|
project(lemonbuddy C CXX)
|
||||||
|
|
||||||
# Include the local cmake modules
|
# Include the local cmake modules
|
||||||
|
@ -12,28 +12,35 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "Release")
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
string(ASCII 27 ANSI)
|
string(ASCII 27 ESC)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Internal values and switches
|
# Project settings
|
||||||
#
|
#
|
||||||
|
|
||||||
# Keep track if the i3 option is explicitly defined
|
# Make the default options based on available libs
|
||||||
if(ENABLE_I3)
|
find_package(ALSA QUIET)
|
||||||
set(ENABLE_I3_NODEF ON)
|
find_package(Libiw QUIET)
|
||||||
|
find_package(LibMPDClient QUIET)
|
||||||
|
find_program(CCACHE_BINARY ccache)
|
||||||
|
if(CCACHE_BINARY)
|
||||||
|
set(CCACHE_FOUND ON)
|
||||||
|
endif()
|
||||||
|
find_program(I3_BINARY i3)
|
||||||
|
if(I3_BINARY)
|
||||||
|
set(I3_FOUND ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(ENABLE_CCACHE "Enable ccache support" ON)
|
option(ENABLE_CCACHE "Enable ccache support" ${CCACHE_FOUND})
|
||||||
option(ENABLE_ALSA "Enable alsa support" ON)
|
option(ENABLE_ALSA "Enable alsa support" ${ALSA_FOUND})
|
||||||
option(ENABLE_I3 "Enable i3 support" ON)
|
option(ENABLE_I3 "Enable i3 support" ${I3_FOUND})
|
||||||
option(ENABLE_MPD "Enable mpd support" ON)
|
option(ENABLE_MPD "Enable mpd support" ${LIBMPDCLIENT_FOUND})
|
||||||
option(ENABLE_NETWORK "Enable network support" ON)
|
option(ENABLE_NETWORK "Enable network support" ${LIBIW_FOUND})
|
||||||
|
|
||||||
if(ENABLE_ALSA)
|
if(ENABLE_ALSA)
|
||||||
set(SETTING_ALSA_SOUNDCARD "default"
|
set(SETTING_ALSA_SOUNDCARD "default"
|
||||||
CACHE STRING "Name of the ALSA soundcard driver")
|
CACHE STRING "Name of the ALSA soundcard driver")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SETTING_CONNECTION_TEST_IP "8.8.8.8"
|
set(SETTING_CONNECTION_TEST_IP "8.8.8.8"
|
||||||
CACHE STRING "Address to ping when testing network connection")
|
CACHE STRING "Address to ping when testing network connection")
|
||||||
set(SETTING_PATH_BACKLIGHT_VAL "/sys/class/backlight/%card%/brightness"
|
set(SETTING_PATH_BACKLIGHT_VAL "/sys/class/backlight/%card%/brightness"
|
||||||
|
@ -54,12 +61,10 @@ set(SETTING_PATH_MEMORY_INFO "/proc/meminfo"
|
||||||
CACHE STRING "Path to file containing memory info")
|
CACHE STRING "Path to file containing memory info")
|
||||||
|
|
||||||
if(ENABLE_CCACHE)
|
if(ENABLE_CCACHE)
|
||||||
find_program(CCACHE_FOUND "ccache")
|
find_program(CCACHE_BINARY ccache REQUIRED)
|
||||||
if(CCACHE_FOUND)
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache")
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache")
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache")
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Locate and insert libs
|
# Locate and insert libs
|
||||||
|
@ -73,14 +78,6 @@ set(PROJECT_LINK_LIBS
|
||||||
${BOOST_LIBRARIES}
|
${BOOST_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT})
|
${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
if(ENABLE_I3)
|
|
||||||
find_program(I3_EXECUTABLE "i3")
|
|
||||||
if(NOT I3_EXECUTABLE)
|
|
||||||
if(NOT ENABLE_I3_NODEF)
|
|
||||||
message(WARNING "${ANSI}[41;1mDisabling \"i3 module\" support (prerequisites failed)${ANSI}[0m")
|
|
||||||
set(ENABLE_I3 OFF)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
if(ENABLE_I3)
|
if(ENABLE_I3)
|
||||||
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/i3ipcpp" EXCLUDE_FROM_ALL)
|
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/i3ipcpp" EXCLUDE_FROM_ALL)
|
||||||
set(PROJECT_INCL_DIRS
|
set(PROJECT_INCL_DIRS
|
||||||
|
@ -91,39 +88,23 @@ if(ENABLE_I3)
|
||||||
${PROJECT_LINK_LIBS}
|
${PROJECT_LINK_LIBS}
|
||||||
${I3IPCPP_LIBRARIES})
|
${I3IPCPP_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ENABLE_ALSA)
|
if(ENABLE_ALSA)
|
||||||
find_package("ALSA")
|
find_package(ALSA REQUIRED)
|
||||||
if(ALSA_FOUND)
|
|
||||||
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${ALSA_INCLUDE_DIR})
|
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${ALSA_INCLUDE_DIR})
|
||||||
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${ALSA_LIBRARY})
|
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${ALSA_LIBRARY})
|
||||||
else(ALSA_FOUND)
|
|
||||||
message(WARNING "${ANSI}[41;1mDisabling \"volume module\" support (prerequisites failed)${ANSI}[0m")
|
|
||||||
set(ENABLE_ALSA OFF)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_MPD)
|
if(ENABLE_MPD)
|
||||||
find_package("LibMPDClient")
|
find_package(LibMPDClient REQUIRED)
|
||||||
if(LIBMPDCLIENT_FOUND)
|
|
||||||
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${LIBMPDCLIENT_INCLUDE_DIR})
|
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${LIBMPDCLIENT_INCLUDE_DIR})
|
||||||
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${LIBMPDCLIENT_LIBRARY})
|
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${LIBMPDCLIENT_LIBRARY})
|
||||||
else(LIBMPDCLIENT_FOUND)
|
|
||||||
message(WARNING "${ANSI}[41;1mDisabling \"mpd module\" support (prerequisites failed)${ANSI}[0m")
|
|
||||||
set(ENABLE_MPD OFF)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_NETWORK)
|
if(ENABLE_NETWORK)
|
||||||
find_package("Libiw")
|
find_package(Libiw REQUIRED)
|
||||||
if(LIBIW_FOUND)
|
|
||||||
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${LIBIW_INCLUDE_DIR})
|
set(PROJECT_INCL_DIRS ${PROJECT_INCL_DIRS} ${LIBIW_INCLUDE_DIR})
|
||||||
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${LIBIW_LIBRARY})
|
set(PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} ${LIBIW_LIBRARY})
|
||||||
else(LIBIW_FOUND)
|
|
||||||
message(WARNING "${ANSI}[41;1mDisabling \"network module\" support (prerequisites failed)${ANSI}[0m")
|
|
||||||
set(ENABLE_NETWORK OFF)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue