fix(build): Add missing files

This commit is contained in:
Michael Carlberg 2016-11-03 13:06:33 +01:00
parent f3b3db9854
commit 74a04ded80
5 changed files with 201 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
build*/ build*/
!cmake/build/
tags tags
*.bak *.bak
*.pyc *.pyc

58
cmake/build/core.cmake Normal file
View File

@ -0,0 +1,58 @@
#
# Core setup
#
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Export compile commands used for custom targets
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set default build type if not specified
if(NOT CMAKE_BUILD_TYPE)
message_colored(STATUS "No build type specified; using Release" 33)
set(CMAKE_BUILD_TYPE "Release")
endif()
# Generic compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
# Debug specific compiler flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g2")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pedantic-errors")
# Release specific compiler flags
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
# Compiler specific flags
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL Clang)
message_colored(STATUS "Using supported compiler ${CMAKE_CXX_COMPILER_ID}" 32)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL GNU)
message_colored(STATUS "Using supported compiler ${CMAKE_CXX_COMPILER_ID}" 32)
else()
message_colored(WARNING "Using unsupported compiler ${CMAKE_CXX_COMPILER_ID} !" 31)
endif()
# Set compiler and linker flags for preferred C++ library
if(CXXLIB_CLANG)
message_colored(STATUS "Linking against libc++" 32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++ -lc++abi")
elseif(CXXLIB_GCC)
message_colored(STATUS "Linking against libstdc++" 32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
else()
message_colored(STATUS "No preferred c++lib specified... linking against system default" 33)
endif()
if(ENABLE_CCACHE)
require_binary(ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${BINPATH_ccache})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${BINPATH_ccache})
endif()

58
cmake/build/options.cmake Normal file
View File

@ -0,0 +1,58 @@
#
# Build options
#
option(CXXLIB_CLANG "Link against libc++" OFF)
option(CXXLIB_GCC "Link against stdlibc++" OFF)
option(BUILD_TESTS "Build testsuite" OFF)
option(DEBUG_LOGGER "Enable extra debug logging" OFF)
option(VERBOSE_TRACELOG "Enable verbose trace logs" OFF)
option(ENABLE_CCACHE "Enable ccache support" OFF)
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)
option(ENABLE_RANDR_EXT "Enable RandR X extension" ON)
option(ENABLE_RENDER_EXT "Enable Render X extension" OFF)
option(ENABLE_DAMAGE_EXT "Enable Damage X extension" OFF)
set(SETTING_ALSA_SOUNDCARD "default"
CACHE STRING "Name of the ALSA soundcard driver")
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")
find_package(ALSA QUIET)
if(NOT ALSA_FOUND)
set(ENABLE_ALSA OFF)
endif()
find_package(Libiw QUIET)
if(NOT LIBIW_FOUND)
set(ENABLE_NETWORK OFF)
endif()
find_package(LibMPDClient QUIET)
if(NOT LIBMPDCLIENT_FOUND)
set(ENABLE_MPD OFF)
endif()
find_program(I3_BINARY i3)
if(NOT I3_BINARY)
set(ENABLE_I3 OFF)
endif()

45
cmake/build/summary.cmake Normal file
View File

@ -0,0 +1,45 @@
#
# Output build summary
#
message(STATUS "---------------------------")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Compiler C: ${CMAKE_C_COMPILER}")
message(STATUS " Compiler C++: ${CMAKE_CXX_COMPILER}")
message(STATUS " Compiler flags: ${CMAKE_CXX_FLAGS}")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS " + debug flags:: ${CMAKE_CXX_FLAGS_DEBUG}")
if(NOT DEFINED ${DEBUG_LOGGER})
set(DEBUG_LOGGER ON)
endif()
if(NOT DEFINED ${ENABLE_CCACHE})
set(ENABLE_CCACHE ON)
endif()
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS " + release flags:: ${CMAKE_CXX_FLAGS_RELEASE}")
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
message(STATUS " + minsizerel flags:: ${CMAKE_CXX_FLAGS_MINSIZEREL}")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
message(STATUS " + relwithdebinfo flags:: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endif()
if(CXXLIB_CLANG)
message(STATUS " Linking C++ library: libc++")
elseif(CXXLIB_GCC)
message(STATUS " Linking C++ library: libstdc++")
else()
message(STATUS " Linking C++ library: system default")
endif()
message(STATUS "---------------------------")
message(STATUS " Build testsuite ${BUILD_TESTS}")
message(STATUS " Enable debug logger ${DEBUG_LOGGER}")
message(STATUS " Enable extra tracing ${VERBOSE_TRACELOG}")
message(STATUS " Enable ccache support ${ENABLE_CCACHE}")
message(STATUS "---------------------------")
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 "---------------------------")

39
cmake/build/targets.cmake Normal file
View File

@ -0,0 +1,39 @@
#
# Custom targets
#
# Target: uninstall {{{
configure_file(
${PROJECT_SOURCE_DIR}/cmake/templates/uninstall.cmake.in
${PROJECT_BINARY_DIR}/uninstall.cmake
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND}
-P ${PROJECT_BINARY_DIR}/cuninstall.cmake)
# }}}
# Target: clang-format {{{
find_program(CLANG_FORMAT "clang-format")
if(CLANG_FORMAT)
file(GLOB_RECURSE HEADERS ${PROJECT_SOURCE_DIR}/include/*.hpp)
file(GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
add_custom_target(clang-format COMMAND ${CLANG_FORMAT}
-i -style=file ${HEADERS} ${SOURCES})
endif()
find_program(CLANG_TIDY "clang-tidy")
# }}}
# Target: clang-tidy {{{
if(CLANG_TIDY)
add_custom_target(clang-tidy
COMMAND ${CLANG_TIDY} -p
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src/main.cpp)
endif()
# }}}