refactor(cmake): Cleanup

This commit is contained in:
Michael Carlberg 2017-01-25 23:28:25 +01:00
parent 886d0f4ff3
commit 37d0a0e57b
6 changed files with 47 additions and 78 deletions

View File

@ -19,6 +19,7 @@ include(build/summary)
add_subdirectory(${PROJECT_SOURCE_DIR}/man) add_subdirectory(${PROJECT_SOURCE_DIR}/man)
add_subdirectory(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/bin) add_subdirectory(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/bin)
add_subdirectory(${PROJECT_SOURCE_DIR}/doc ${PROJECT_BINARY_DIR}/doc) add_subdirectory(${PROJECT_SOURCE_DIR}/doc ${PROJECT_BINARY_DIR}/doc)
add_subdirectory(${PROJECT_SOURCE_DIR}/doc/zsh ${PROJECT_BINARY_DIR}/doc/zsh)
if(BUILD_TESTS) if(BUILD_TESTS)
add_subdirectory(${PROJECT_SOURCE_DIR}/tests ${PROJECT_BINARY_DIR}/tests) add_subdirectory(${PROJECT_SOURCE_DIR}/tests ${PROJECT_BINARY_DIR}/tests)

View File

@ -6,11 +6,12 @@
configure_file( configure_file(
${PROJECT_SOURCE_DIR}/cmake/templates/userconfig.cmake.in ${PROJECT_SOURCE_DIR}/cmake/templates/userconfig.cmake.in
${PROJECT_BINARY_DIR}/userconfig.cmake ${PROJECT_BINARY_DIR}/cmake/userconfig.cmake
IMMEDIATE @ONLY) ESCAPE_QUOTES @ONLY)
add_custom_target(userconfig COMMAND ${CMAKE_COMMAND} add_custom_target(userconfig
-P ${PROJECT_BINARY_DIR}/userconfig.cmake) DEPENDS ${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/cmake/userconfig.cmake)
# }}} # }}}
# Target: uninstall {{{ # Target: uninstall {{{
@ -18,48 +19,55 @@ add_custom_target(userconfig COMMAND ${CMAKE_COMMAND}
configure_file( configure_file(
${PROJECT_SOURCE_DIR}/cmake/templates/uninstall.cmake.in ${PROJECT_SOURCE_DIR}/cmake/templates/uninstall.cmake.in
${PROJECT_BINARY_DIR}/cmake/uninstall.cmake ${PROJECT_BINARY_DIR}/cmake/uninstall.cmake
IMMEDIATE @ONLY) ESCAPE_QUOTES @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} add_custom_target(uninstall
-P ${PROJECT_BINARY_DIR}/cmake/uninstall.cmake) COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/cmake/uninstall.cmake)
# }}} # }}}
# Target: codeformat (clang-format) {{{ # Target: codeformat (clang-format) {{{
add_custom_target(codeformat) add_custom_target(codeformat)
add_custom_command(TARGET codeformat COMMAND add_custom_command(TARGET codeformat
${PROJECT_SOURCE_DIR}/common/clang-format.sh ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/include) COMMAND ${PROJECT_SOURCE_DIR}/common/clang-format.sh
${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/include)
# }}} # }}}
# Target: codecheck (clang-tidy) {{{ # Target: codecheck (clang-tidy) {{{
add_custom_target(codecheck) add_custom_target(codecheck)
add_custom_command(TARGET codecheck COMMAND add_custom_command(TARGET codecheck
${PROJECT_SOURCE_DIR}/common/clang-tidy.sh ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src) COMMAND ${PROJECT_SOURCE_DIR}/common/clang-tidy.sh
${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src)
# }}} # }}}
# Target: codecheck-fix (clang-tidy + clang-format) {{{ # Target: codecheck-fix (clang-tidy + clang-format) {{{
add_custom_target(codecheck-fix) add_custom_target(codecheck-fix)
add_custom_command(TARGET codecheck-fix COMMAND add_custom_command(TARGET codecheck-fix
${PROJECT_SOURCE_DIR}/common/clang-tidy.sh ${PROJECT_BINARY_DIR} -fix ${PROJECT_SOURCE_DIR}/src) COMMAND ${PROJECT_SOURCE_DIR}/common/clang-tidy.sh
${PROJECT_BINARY_DIR} -fix ${PROJECT_SOURCE_DIR}/src)
# }}} # }}}
# Target: memcheck (valgrind) {{{ # Target: memcheck (valgrind) {{{
add_custom_target(memcheck) add_custom_target(memcheck)
add_custom_command(TARGET memcheck COMMAND valgrind add_custom_command(TARGET memcheck
COMMAND valgrind
--leak-check=summary --leak-check=summary
--suppressions=${PROJECT_SOURCE_DIR}/.valgrind-suppressions --suppressions=${PROJECT_SOURCE_DIR}/.valgrind-suppressions
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME} example --config=${PROJECT_SOURCE_DIR}/doc/config) ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}
example --config=${PROJECT_SOURCE_DIR}/doc/config)
add_custom_target(memcheck-full) add_custom_target(memcheck-full)
add_custom_command(TARGET memcheck-full COMMAND valgrind add_custom_command(TARGET memcheck-full
COMMAND valgrind
--leak-check=full --leak-check=full
--track-origins=yes --track-origins=yes
--track-fds=yes --track-fds=yes
--suppressions=${PROJECT_SOURCE_DIR}/.valgrind-suppressions --suppressions=${PROJECT_SOURCE_DIR}/.valgrind-suppressions
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME} example --config=${PROJECT_SOURCE_DIR}/doc/config) ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}
example --config=${PROJECT_SOURCE_DIR}/doc/config)
# }}} # }}}

View File

@ -1,31 +0,0 @@
# - Try to find libX11-xcb
# Once done this will define
#
# X11_XCB_FOUND - system has libX11-xcb
# X11_XCB_LIBRARIES - Link these to use libX11-xcb
# X11_XCB_INCLUDE_DIR - the libX11-xcb include dir
# X11_XCB_DEFINITIONS - compiler switches required for using libX11-xcb
# Copyright (c) 2011 Fredrik Höglund <fredrik@kde.org>
# Copyright (c) 2008 Helio Chissini de Castro, <helio@kde.org>
# Copyright (c) 2007 Matthias Kretz, <kretz@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PKG_X11_XCB QUIET x11-xcb)
SET(X11_XCB_DEFINITIONS ${PKG_X11_XCB_CFLAGS})
FIND_PATH(X11_XCB_INCLUDE_DIR NAMES X11/Xlib-xcb.h HINTS ${PKG_X11_XCB_INCLUDE_DIRS})
FIND_LIBRARY(X11_XCB_LIBRARIES NAMES X11-xcb HINTS ${PKG_X11_XCB_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(X11_XCB DEFAULT_MSG X11_XCB_LIBRARIES X11_XCB_INCLUDE_DIR)
MARK_AS_ADVANCED(X11_XCB_INCLUDE_DIR X11_XCB_LIBRARIES)
ENDIF (NOT WIN32)

View File

@ -1,26 +1,23 @@
set(INSTALL_MANIFEST "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") set(INSTALL_MANIFEST "@CMAKE_CURRENT_BINARY_DIR@/install_manifest")
if(NOT EXISTS ${INSTALL_MANIFEST})
message(FATAL_ERROR "Cannot find install manifest: ${INSTALL_MANIFEST}")
endif()
if (NOT EXISTS ${INSTALL_MANIFEST}) file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest" files)
message(FATAL_ERROR
"Cannot find install manifest:
\"${INSTALL_MANIFEST}\"")
endif(NOT EXISTS ${INSTALL_MANIFEST})
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}") string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files) list(REVERSE files)
foreach (file ${files}) foreach(file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if (EXISTS "$ENV{DESTDIR}${file}") if(EXISTS "$ENV{DESTDIR}${file}")
execute_process( execute_process(COMMAND "@CMAKE_COMMAND@"
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval) RESULT_VARIABLE rm_retval)
if(NOT ${rm_retval} EQUAL 0) if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif (NOT ${rm_retval} EQUAL 0) endif()
else (EXISTS "$ENV{DESTDIR}${file}") else()
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") message(STATUS "File $ENV{DESTDIR}${file} does not exist")
endif (EXISTS "$ENV{DESTDIR}${file}") endif()
endforeach(file) endforeach()

View File

@ -1,7 +1,8 @@
set(USER_CONFIG_HOME $ENV{XDG_CONFIG_HOME}) set(USER_CONFIG_HOME "$ENV{XDG_CONFIG_HOME}")
if(NOT USER_CONFIG_HOME) if(NOT USER_CONFIG_HOME)
set(USER_CONFIG_HOME $ENV{HOME}/.config) set(USER_CONFIG_HOME "$ENV{HOME}/.config")
endif() endif()
set(USER_CONFIG_HOME ${USER_CONFIG_HOME}/polybar) set(USER_CONFIG_HOME "${USER_CONFIG_HOME}/polybar")
file(INSTALL @CMAKE_SOURCE_DIR@/doc/config DESTINATION ${USER_CONFIG_HOME}) file(INSTALL "@CMAKE_SOURCE_DIR@/doc/config"
DESTINATION "${USER_CONFIG_HOME}")

View File

@ -2,8 +2,6 @@
# Generate configuration file # Generate configuration file
# #
add_subdirectory(zsh)
set(MODULES_LEFT "bspwm i3") set(MODULES_LEFT "bspwm i3")
set(MODULES_CENTER "mpd") set(MODULES_CENTER "mpd")
set(MODULES_RIGHT "xbacklight volume xkeyboard memory cpu wlan eth battery temperature date powermenu") set(MODULES_RIGHT "xbacklight volume xkeyboard memory cpu wlan eth battery temperature date powermenu")
@ -42,16 +40,13 @@ endif()
string(REGEX REPLACE /%battery%.* "" PATH_BAT ${SETTING_PATH_BATTERY}) string(REGEX REPLACE /%battery%.* "" PATH_BAT ${SETTING_PATH_BATTERY})
string(REGEX REPLACE /%adapter%.* "" PATH_ADP ${SETTING_PATH_ADAPTER}) string(REGEX REPLACE /%adapter%.* "" PATH_ADP ${SETTING_PATH_ADAPTER})
file(GLOB BAT_LIST RELATIVE ${PATH_BAT} ${PATH_ADP}/B*) file(GLOB BAT_LIST RELATIVE ${PATH_BAT} ${PATH_ADP}/B*)
file(GLOB ADP_LIST RELATIVE ${PATH_ADP} ${PATH_ADP}/A*) file(GLOB ADP_LIST RELATIVE ${PATH_ADP} ${PATH_ADP}/A*)
if(BAT_LIST) if(BAT_LIST)
list(GET BAT_LIST 0 BATTERY) list(GET BAT_LIST 0 BATTERY)
else() else()
set(BATTERY BAT0) set(BATTERY BAT0)
endif() endif()
if(ADP_LIST) if(ADP_LIST)
list(GET ADP_LIST 0 ADAPTER) list(GET ADP_LIST 0 ADAPTER)
else() else()
@ -63,7 +58,6 @@ endif()
if(ENABLE_NETWORK) if(ENABLE_NETWORK)
file(GLOB IFLIST RELATIVE /sys/class/net /sys/class/net/*) file(GLOB IFLIST RELATIVE /sys/class/net /sys/class/net/*)
foreach(INTERFACE ${IFLIST}) foreach(INTERFACE ${IFLIST})
if(NOT ${INTERFACE} STREQUAL "lo") if(NOT ${INTERFACE} STREQUAL "lo")
file(GLOB IS_WIRELESS /sys/class/net/${INTERFACE}/wireless) file(GLOB IS_WIRELESS /sys/class/net/${INTERFACE}/wireless)
@ -74,7 +68,6 @@ if(ENABLE_NETWORK)
endif() endif()
endif() endif()
endforeach() endforeach()
if(NOT INTERFACE_ETH) if(NOT INTERFACE_ETH)
set(INTERFACE_ETH net0) set(INTERFACE_ETH net0)
endif() endif()