Пересобранный и видоизмененный conky для ОСГОС
This commit is contained in:
commit
3a48cf8c86
738 changed files with 217718 additions and 0 deletions
172
cmake/Catch.cmake
Normal file
172
cmake/Catch.cmake
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
Catch
|
||||
-----
|
||||
|
||||
This module defines a function to help use the Catch test framework.
|
||||
|
||||
The :command:`catch_discover_tests` discovers tests by asking the compiled test
|
||||
executable to enumerate its tests. This does not require CMake to be re-run
|
||||
when tests change. However, it may not work in a cross-compiling environment,
|
||||
and setting test properties is less convenient.
|
||||
|
||||
This command is intended to replace use of :command:`add_test` to register
|
||||
tests, and will create a separate CTest test for each Catch test case. Note
|
||||
that this is in some cases less efficient, as common set-up and tear-down logic
|
||||
cannot be shared by multiple test cases executing in the same instance.
|
||||
However, it provides more fine-grained pass/fail information to CTest, which is
|
||||
usually considered as more beneficial. By default, the CTest test name is the
|
||||
same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
|
||||
|
||||
.. command:: catch_discover_tests
|
||||
|
||||
Automatically add tests with CTest by querying the compiled test executable
|
||||
for available tests::
|
||||
|
||||
catch_discover_tests(target
|
||||
[TEST_SPEC arg1...]
|
||||
[EXTRA_ARGS arg1...]
|
||||
[WORKING_DIRECTORY dir]
|
||||
[TEST_PREFIX prefix]
|
||||
[TEST_SUFFIX suffix]
|
||||
[PROPERTIES name1 value1...]
|
||||
[TEST_LIST var]
|
||||
)
|
||||
|
||||
``catch_discover_tests`` sets up a post-build command on the test executable
|
||||
that generates the list of tests by parsing the output from running the test
|
||||
with the ``--list-test-names-only`` argument. This ensures that the full
|
||||
list of tests is obtained. Since test discovery occurs at build time, it is
|
||||
not necessary to re-run CMake when the list of tests changes.
|
||||
However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set
|
||||
in order to function in a cross-compiling environment.
|
||||
|
||||
Additionally, setting properties on tests is somewhat less convenient, since
|
||||
the tests are not available at CMake time. Additional test properties may be
|
||||
assigned to the set of tests as a whole using the ``PROPERTIES`` option. If
|
||||
more fine-grained test control is needed, custom content may be provided
|
||||
through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES`
|
||||
directory property. The set of discovered tests is made accessible to such a
|
||||
script via the ``<target>_TESTS`` variable.
|
||||
|
||||
The options are:
|
||||
|
||||
``target``
|
||||
Specifies the Catch executable, which must be a known CMake executable
|
||||
target. CMake will substitute the location of the built executable when
|
||||
running the test.
|
||||
|
||||
``TEST_SPEC arg1...``
|
||||
Specifies test cases, wildcarded test cases, tags and tag expressions to
|
||||
pass to the Catch executable with the ``--list-test-names-only`` argument.
|
||||
|
||||
``EXTRA_ARGS arg1...``
|
||||
Any extra arguments to pass on the command line to each test case.
|
||||
|
||||
``WORKING_DIRECTORY dir``
|
||||
Specifies the directory in which to run the discovered test cases. If this
|
||||
option is not provided, the current binary directory is used.
|
||||
|
||||
``TEST_PREFIX prefix``
|
||||
Specifies a ``prefix`` to be prepended to the name of each discovered test
|
||||
case. This can be useful when the same test executable is being used in
|
||||
multiple calls to ``catch_discover_tests()`` but with different
|
||||
``TEST_SPEC`` or ``EXTRA_ARGS``.
|
||||
|
||||
``TEST_SUFFIX suffix``
|
||||
Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
|
||||
every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
|
||||
be specified.
|
||||
|
||||
``PROPERTIES name1 value1...``
|
||||
Specifies additional properties to be set on all tests discovered by this
|
||||
invocation of ``catch_discover_tests``.
|
||||
|
||||
``TEST_LIST var``
|
||||
Make the list of tests available in the variable ``var``, rather than the
|
||||
default ``<target>_TESTS``. This can be useful when the same test
|
||||
executable is being used in multiple calls to ``catch_discover_tests()``.
|
||||
Note that this variable is only available in CTest.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
function(catch_discover_tests TARGET)
|
||||
cmake_parse_arguments(""
|
||||
""
|
||||
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST"
|
||||
"TEST_SPEC;EXTRA_ARGS;PROPERTIES"
|
||||
${ARGN})
|
||||
|
||||
if(NOT _WORKING_DIRECTORY)
|
||||
set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
if(NOT _TEST_LIST)
|
||||
set(_TEST_LIST ${TARGET}_TESTS)
|
||||
endif()
|
||||
|
||||
# Generate a unique name based on the extra arguments
|
||||
string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}")
|
||||
string(SUBSTRING ${args_hash}
|
||||
0
|
||||
7
|
||||
args_hash)
|
||||
|
||||
# Define rule to generate test list for aforementioned test executable
|
||||
set(ctest_include_file
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake")
|
||||
set(ctest_tests_file
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake")
|
||||
get_property(crosscompiling_emulator
|
||||
TARGET ${TARGET}
|
||||
PROPERTY CROSSCOMPILING_EMULATOR)
|
||||
add_custom_command(TARGET
|
||||
${TARGET}
|
||||
POST_BUILD
|
||||
BYPRODUCTS
|
||||
"${ctest_tests_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -D "TEST_TARGET=${TARGET}" -D
|
||||
"TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>" -D
|
||||
"TEST_EXECUTOR=${crosscompiling_emulator}" -D
|
||||
"TEST_WORKING_DIR=${_WORKING_DIRECTORY}" -D
|
||||
"TEST_SPEC=${_TEST_SPEC}" -D
|
||||
"TEST_EXTRA_ARGS=${_EXTRA_ARGS}" -D
|
||||
"TEST_PROPERTIES=${_PROPERTIES}" -D
|
||||
"TEST_PREFIX=${_TEST_PREFIX}" -D
|
||||
"TEST_SUFFIX=${_TEST_SUFFIX}" -D
|
||||
"TEST_LIST=${_TEST_LIST}" -D
|
||||
"CTEST_FILE=${ctest_tests_file}" -P
|
||||
"${_CATCH_DISCOVER_TESTS_SCRIPT}"
|
||||
VERBATIM)
|
||||
|
||||
file(
|
||||
WRITE
|
||||
"${ctest_include_file}"
|
||||
"if(EXISTS \"${ctest_tests_file}\")\n"
|
||||
" include(\"${ctest_tests_file}\")\n"
|
||||
"else()\n"
|
||||
" add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n"
|
||||
"endif()\n")
|
||||
|
||||
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
|
||||
# Add discovered tests to directory TEST_INCLUDE_FILES
|
||||
set_property(DIRECTORY
|
||||
APPEND
|
||||
PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}")
|
||||
else()
|
||||
# Add discovered tests as directory TEST_INCLUDE_FILE if possible
|
||||
get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET)
|
||||
if(NOT ${test_include_file_set})
|
||||
set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}")
|
||||
else()
|
||||
message(FATAL_ERROR "Cannot set more than one TEST_INCLUDE_FILE")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
#
|
||||
|
||||
set(_CATCH_DISCOVER_TESTS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake)
|
||||
77
cmake/CatchAddTests.cmake
Normal file
77
cmake/CatchAddTests.cmake
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
set(prefix "${TEST_PREFIX}")
|
||||
set(suffix "${TEST_SUFFIX}")
|
||||
set(spec ${TEST_SPEC})
|
||||
set(extra_args ${TEST_EXTRA_ARGS})
|
||||
set(properties ${TEST_PROPERTIES})
|
||||
set(script)
|
||||
set(suite)
|
||||
set(tests)
|
||||
|
||||
function(add_command NAME)
|
||||
set(_args "")
|
||||
foreach(_arg ${ARGN})
|
||||
if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
|
||||
set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument
|
||||
else()
|
||||
set(_args "${_args} ${_arg}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Run test executable to get list of available tests
|
||||
if(NOT EXISTS "${TEST_EXECUTABLE}")
|
||||
message(
|
||||
FATAL_ERROR "Specified test executable '${TEST_EXECUTABLE}' does not exist")
|
||||
endif()
|
||||
execute_process(COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec}
|
||||
--list-test-names-only
|
||||
OUTPUT_VARIABLE output
|
||||
RESULT_VARIABLE result)
|
||||
# Catch --list-test-names-only reports the number of tests, so 0 is...
|
||||
# surprising
|
||||
if(${result} EQUAL 0)
|
||||
message(WARNING "Test executable '${TEST_EXECUTABLE}' contains no tests!\n")
|
||||
elseif(${result} LESS 0)
|
||||
message(FATAL_ERROR "Error running test executable '${TEST_EXECUTABLE}':\n"
|
||||
" Result: ${result}\n" " Output: ${output}\n")
|
||||
endif()
|
||||
|
||||
string(REPLACE "\n"
|
||||
";"
|
||||
output
|
||||
"${output}")
|
||||
|
||||
# Parse output
|
||||
foreach(line ${output})
|
||||
set(test ${line})
|
||||
# use escape commas to handle properly test cases with commans inside the name
|
||||
string(REPLACE ","
|
||||
"\\,"
|
||||
test_name
|
||||
${test})
|
||||
# ...and add to script
|
||||
add_command(add_test
|
||||
"${prefix}${test}${suffix}"
|
||||
${TEST_EXECUTOR}
|
||||
"${TEST_EXECUTABLE}"
|
||||
"${test_name}"
|
||||
${extra_args})
|
||||
add_command(set_tests_properties
|
||||
"${prefix}${test}${suffix}"
|
||||
PROPERTIES
|
||||
WORKING_DIRECTORY
|
||||
"${TEST_WORKING_DIR}"
|
||||
${properties})
|
||||
list(APPEND tests "${prefix}${test}${suffix}")
|
||||
endforeach()
|
||||
|
||||
# Create a list of all discovered tests, which users may use to e.g. set
|
||||
# properties on the tests
|
||||
add_command(set ${TEST_LIST} ${tests})
|
||||
|
||||
# Write CTest script
|
||||
file(WRITE "${CTEST_FILE}" "${script}")
|
||||
420
cmake/CodeCoverage.cmake
Normal file
420
cmake/CodeCoverage.cmake
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
# Copyright (c) 2012 - 2017, Lars Bilke All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# 1. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# 1. Neither the name of the copyright holder nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# CHANGES:
|
||||
#
|
||||
# 2012-01-31, Lars Bilke - Enable Code Coverage
|
||||
#
|
||||
# 2013-09-17, Joakim Söderberg - Added support for Clang. - Some additional
|
||||
# usage instructions.
|
||||
#
|
||||
# 2016-02-03, Lars Bilke - Refactored functions to use named parameters
|
||||
#
|
||||
# 2017-06-02, Lars Bilke - Merged with modified version from github.com/ufz/ogs
|
||||
#
|
||||
# USAGE:
|
||||
#
|
||||
# 1. Copy this file into your cmake modules path.
|
||||
#
|
||||
# 1. Add the following line to your CMakeLists.txt: include(CodeCoverage)
|
||||
#
|
||||
# 1. Append necessary compiler flags: APPEND_COVERAGE_COMPILER_FLAGS()
|
||||
#
|
||||
# 1. If you need to exclude additional directories from the report, specify them
|
||||
# using the COVERAGE_LCOV_EXCLUDES variable before calling
|
||||
# SETUP_TARGET_FOR_COVERAGE_LCOV. Example: set(COVERAGE_LCOV_EXCLUDES 'dir1/*'
|
||||
# 'dir2/*')
|
||||
#
|
||||
# 1. Use the functions described below to create a custom make target which runs
|
||||
# your test executable and produces a code coverage report.
|
||||
#
|
||||
# 1. Build a Debug build: cmake -DCMAKE_BUILD_TYPE=Debug .. make make
|
||||
# my_coverage_target
|
||||
#
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# Check prereqs
|
||||
find_program(GCOV_PATH
|
||||
NAMES ${CMAKE_SOURCE_DIR}/tests/llvm-gcov.sh gcov
|
||||
PATHS ENV PATH)
|
||||
find_program(LCOV_PATH
|
||||
NAMES lcov
|
||||
lcov.bat
|
||||
lcov.exe
|
||||
lcov.perl
|
||||
PATHS ENV PATH)
|
||||
find_program(LLVM_COV_PATH
|
||||
NAMES
|
||||
llvm-cov110
|
||||
llvm-cov-11
|
||||
llvm-cov100
|
||||
llvm-cov-10
|
||||
llvm-cov90
|
||||
llvm-cov-9
|
||||
llvm-cov80
|
||||
llvm-cov-8
|
||||
llvm-cov70
|
||||
llvm-cov-7
|
||||
llvm-cov
|
||||
PATHS ENV PATH)
|
||||
find_program(LLVM_PROFDATA_PATH
|
||||
NAMES
|
||||
llvm-profdata110
|
||||
llvm-profdata-11
|
||||
llvm-profdata100
|
||||
llvm-profdata-10
|
||||
llvm-profdata90
|
||||
llvm-profdata-9
|
||||
llvm-profdata80
|
||||
llvm-profdata-8
|
||||
llvm-profdata70
|
||||
llvm-profdata-7
|
||||
llvm-profdata
|
||||
PATHS ENV PATH)
|
||||
find_program(GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat)
|
||||
find_program(GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
|
||||
find_program(SIMPLE_PYTHON_EXECUTABLE python)
|
||||
|
||||
if(NOT GCOV_PATH)
|
||||
message(FATAL_ERROR "gcov not found! Aborting...")
|
||||
endif() # NOT GCOV_PATH
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
|
||||
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
|
||||
message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
|
||||
endif()
|
||||
elseif(NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||
message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
|
||||
endif()
|
||||
|
||||
set(
|
||||
COVERAGE_COMPILER_FLAGS
|
||||
-g -O0 -fprofile-arcs -ftest-coverage -fprofile-instr-generate -fcoverage-mapping
|
||||
CACHE INTERNAL "")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE ${COVERAGE_COMPILER_FLAGS}
|
||||
CACHE STRING "Flags used by the C++ compiler during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_C_FLAGS_COVERAGE ${COVERAGE_COMPILER_FLAGS}
|
||||
CACHE STRING "Flags used by the C compiler during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE ""
|
||||
CACHE STRING "Flags used for linking binaries during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE ""
|
||||
CACHE STRING
|
||||
"Flags used by the shared libraries linker during coverage builds."
|
||||
FORCE)
|
||||
mark_as_advanced(CMAKE_CXX_FLAGS_COVERAGE
|
||||
CMAKE_C_FLAGS_COVERAGE
|
||||
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||
CMAKE_SHARED_LINKER_FLAGS_COVERAGE)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message(
|
||||
WARNING
|
||||
"Code coverage results with an optimised (non-Debug) build may be misleading"
|
||||
)
|
||||
endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
link_libraries(gcov)
|
||||
else()
|
||||
add_link_options($<$<NOT:$<COMPILE_LANG_AND_ID:C,GNU>>:-fprofile-instr-generate>)
|
||||
endif()
|
||||
|
||||
# Defines a target for running and collection code coverage information Builds
|
||||
# dependencies, runs the given executable and outputs reports. NOTE! The
|
||||
# executable should always have a ZERO as exit code otherwise the coverage
|
||||
# generation will not complete.
|
||||
#
|
||||
# SETUP_TARGET_FOR_COVERAGE_LCOV_HTML( NAME testrunner_coverage # New target
|
||||
# name EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in
|
||||
# PROJECT_BINARY_DIR DEPENDENCIES testrunner # Dependencies
|
||||
# to build first )
|
||||
function(SETUP_TARGET_FOR_COVERAGE_LCOV_HTML)
|
||||
|
||||
set(options NONE)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs
|
||||
EXECUTABLE
|
||||
EXECUTABLE_ARGS
|
||||
DEPENDENCIES
|
||||
LCOV_ARGS
|
||||
GENHTML_ARGS)
|
||||
cmake_parse_arguments(Coverage
|
||||
"${options}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
|
||||
if(NOT LCOV_PATH)
|
||||
message(FATAL_ERROR "lcov not found! Aborting...")
|
||||
endif() # NOT LCOV_PATH
|
||||
|
||||
if(NOT GENHTML_PATH)
|
||||
message(FATAL_ERROR "genhtml not found! Aborting...")
|
||||
endif() # NOT GENHTML_PATH
|
||||
|
||||
# Setup target
|
||||
add_custom_target(
|
||||
${Coverage_NAME}
|
||||
# Cleanup lcov
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS}
|
||||
--gcov-tool ${GCOV_PATH} -directory .
|
||||
--zerocounters # Create baseline to make sure untouched files show
|
||||
# up in the report
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS}
|
||||
--gcov-tool ${GCOV_PATH} -c -i -d . -o ${Coverage_NAME}.base
|
||||
# Run tests
|
||||
COMMAND ${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||
# Capturing lcov counters and generating report
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS}
|
||||
--gcov-tool ${GCOV_PATH}
|
||||
--directory .
|
||||
--capture
|
||||
--output-file ${Coverage_NAME}.info
|
||||
# add baseline counters
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS}
|
||||
--gcov-tool ${GCOV_PATH} -a ${Coverage_NAME}.base -a
|
||||
${Coverage_NAME}.info
|
||||
--output-file ${Coverage_NAME}.total
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS}
|
||||
--gcov-tool ${GCOV_PATH}
|
||||
--remove ${Coverage_NAME}.total ${COVERAGE_LCOV_EXCLUDES}
|
||||
--output-file ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
|
||||
# Generate HTML
|
||||
COMMAND ${GENHTML_PATH} ${Coverage_GENHTML_ARGS} -o ${Coverage_NAME}
|
||||
${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
|
||||
# Clean up
|
||||
COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base
|
||||
${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS ${Coverage_DEPENDENCIES}
|
||||
COMMENT
|
||||
"Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
|
||||
)
|
||||
|
||||
# Show where to find the lcov info report
|
||||
add_custom_command(
|
||||
TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT
|
||||
"Lcov code coverage info report saved in ${Coverage_NAME}.info.cleaned")
|
||||
|
||||
# Show info where to find the report
|
||||
add_custom_command(
|
||||
TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT
|
||||
"Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
|
||||
)
|
||||
|
||||
endfunction() # SETUP_TARGET_FOR_COVERAGE_LCOV_HTML
|
||||
|
||||
# Defines a target for running and collection code coverage information Builds
|
||||
# dependencies, runs the given executable and outputs reports. NOTE! The
|
||||
# executable should always have a ZERO as exit code otherwise the coverage
|
||||
# generation will not complete.
|
||||
#
|
||||
# SETUP_TARGET_FOR_COVERAGE_LCOV_TXT( NAME testrunner_coverage # New target name
|
||||
# EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
|
||||
# DEPENDENCIES testrunner # Dependencies to build first )
|
||||
function(SETUP_TARGET_FOR_COVERAGE_LCOV_TXT)
|
||||
|
||||
set(options NONE)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs
|
||||
EXECUTABLE
|
||||
EXECUTABLE_ARGS
|
||||
DEPENDENCIES
|
||||
LCOV_ARGS
|
||||
GENHTML_ARGS)
|
||||
cmake_parse_arguments(Coverage
|
||||
"${options}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
|
||||
if(NOT LCOV_PATH)
|
||||
message(FATAL_ERROR "lcov not found! Aborting...")
|
||||
endif() # NOT LCOV_PATH
|
||||
|
||||
# Setup target
|
||||
add_custom_target(
|
||||
${Coverage_NAME}
|
||||
# Run tests
|
||||
COMMAND ${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||
# Generate coverage.txt for sonar
|
||||
COMMAND ${LLVM_PROFDATA_PATH} merge default.profraw -output
|
||||
${Coverage_NAME}.profdata
|
||||
COMMAND ${LLVM_COV_PATH} show -instr-profile=${Coverage_NAME}.profdata
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${Coverage_EXECUTABLE} >
|
||||
${Coverage_NAME}.txt
|
||||
# Generate HTML
|
||||
# Clean up
|
||||
COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.profdata default.profraw
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS ${Coverage_DEPENDENCIES}
|
||||
COMMENT
|
||||
"Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
|
||||
)
|
||||
|
||||
# Show where to find the lcov info report
|
||||
add_custom_command(
|
||||
TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT "Lcov code coverage info report saved in ${Coverage_NAME}.txt.")
|
||||
|
||||
endfunction() # SETUP_TARGET_FOR_COVERAGE_LCOV_TXT
|
||||
|
||||
# Defines a target for running and collection code coverage information Builds
|
||||
# dependencies, runs the given executable and outputs reports. NOTE! The
|
||||
# executable should always have a ZERO as exit code otherwise the coverage
|
||||
# generation will not complete.
|
||||
#
|
||||
# SETUP_TARGET_FOR_COVERAGE_GCOVR_XML( NAME ctest_coverage #
|
||||
# New target name EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in
|
||||
# PROJECT_BINARY_DIR DEPENDENCIES executable_target # Dependencies to
|
||||
# build first )
|
||||
function(SETUP_TARGET_FOR_COVERAGE_GCOVR_XML)
|
||||
|
||||
set(options NONE)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
|
||||
cmake_parse_arguments(Coverage
|
||||
"${options}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
|
||||
if(NOT SIMPLE_PYTHON_EXECUTABLE)
|
||||
message(FATAL_ERROR "python not found! Aborting...")
|
||||
endif() # NOT SIMPLE_PYTHON_EXECUTABLE
|
||||
|
||||
if(NOT GCOVR_PATH)
|
||||
message(FATAL_ERROR "gcovr not found! Aborting...")
|
||||
endif() # NOT GCOVR_PATH
|
||||
|
||||
# Combine excludes to several -e arguments
|
||||
set(GCOVR_EXCLUDES "")
|
||||
foreach(EXCLUDE ${COVERAGE_GCOVR_EXCLUDES})
|
||||
list(APPEND GCOVR_EXCLUDES "-e")
|
||||
list(APPEND GCOVR_EXCLUDES "${EXCLUDE}")
|
||||
endforeach()
|
||||
|
||||
add_custom_target(
|
||||
${Coverage_NAME}
|
||||
# Run tests
|
||||
${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||
# Running gcovr
|
||||
COMMAND ${GCOVR_PATH}
|
||||
--xml -r ${PROJECT_SOURCE_DIR} ${GCOVR_EXCLUDES}
|
||||
--object-directory=${PROJECT_BINARY_DIR} -o ${Coverage_NAME}.xml
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS ${Coverage_DEPENDENCIES}
|
||||
COMMENT "Running gcovr to produce Cobertura code coverage report.")
|
||||
|
||||
# Show info where to find the report
|
||||
add_custom_command(
|
||||
TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml.")
|
||||
|
||||
endfunction() # SETUP_TARGET_FOR_COVERAGE_GCOVR_XML
|
||||
|
||||
# Defines a target for running and collection code coverage information Builds
|
||||
# dependencies, runs the given executable and outputs reports. NOTE! The
|
||||
# executable should always have a ZERO as exit code otherwise the coverage
|
||||
# generation will not complete.
|
||||
#
|
||||
# SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML( NAME ctest_coverage #
|
||||
# New target name EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in
|
||||
# PROJECT_BINARY_DIR DEPENDENCIES executable_target # Dependencies to
|
||||
# build first )
|
||||
function(SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML)
|
||||
|
||||
set(options NONE)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
|
||||
cmake_parse_arguments(Coverage
|
||||
"${options}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
|
||||
if(NOT SIMPLE_PYTHON_EXECUTABLE)
|
||||
message(FATAL_ERROR "python not found! Aborting...")
|
||||
endif() # NOT SIMPLE_PYTHON_EXECUTABLE
|
||||
|
||||
if(NOT GCOVR_PATH)
|
||||
message(FATAL_ERROR "gcovr not found! Aborting...")
|
||||
endif() # NOT GCOVR_PATH
|
||||
|
||||
# Combine excludes to several -e arguments
|
||||
set(GCOVR_EXCLUDES "")
|
||||
foreach(EXCLUDE ${COVERAGE_GCOVR_EXCLUDES})
|
||||
list(APPEND GCOVR_EXCLUDES "-e")
|
||||
list(APPEND GCOVR_EXCLUDES "${EXCLUDE}")
|
||||
endforeach()
|
||||
|
||||
add_custom_target(
|
||||
${Coverage_NAME}
|
||||
# Run tests
|
||||
${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||
# Create folder
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
${PROJECT_BINARY_DIR}/${Coverage_NAME}
|
||||
# Running gcovr
|
||||
COMMAND ${GCOVR_PATH}
|
||||
--html
|
||||
--html-details -r ${PROJECT_SOURCE_DIR} ${GCOVR_EXCLUDES}
|
||||
--object-directory=${PROJECT_BINARY_DIR} -o
|
||||
${Coverage_NAME}/index.html
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS ${Coverage_DEPENDENCIES}
|
||||
COMMENT "Running gcovr to produce HTML code coverage report.")
|
||||
|
||||
# Show info where to find the report
|
||||
add_custom_command(
|
||||
TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT
|
||||
"Open ${CMAKE_CURRENT_BINARY_DIR}/${Coverage_NAME}/index.html in your browser to view the coverage report."
|
||||
)
|
||||
|
||||
endfunction() # SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML
|
||||
|
||||
function(APPEND_COVERAGE_COMPILER_FLAGS)
|
||||
foreach(_opt ${COVERAGE_COMPILER_FLAGS})
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C>:${_opt}>)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${_opt}>)
|
||||
endforeach()
|
||||
message(
|
||||
STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}")
|
||||
endfunction() # APPEND_COVERAGE_COMPILER_FLAGS
|
||||
243
cmake/Conky.cmake
Normal file
243
cmake/Conky.cmake
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
#
|
||||
# Conky, a system monitor, based on torsmo
|
||||
#
|
||||
# Please see COPYING for details
|
||||
#
|
||||
# Copyright (c) 2005-2024 Brenden Matthews, et. al. (see AUTHORS) All rights
|
||||
# reserved.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details. You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# set(RELEASE true)
|
||||
|
||||
# Set system vars
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(OS_LINUX true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
set(OS_FREEBSD true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
set(OS_DRAGONFLY true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
set(OS_OPENBSD true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
set(OS_SOLARIS true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
set(OS_NETBSD true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||
set(OS_HAIKU true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(OS_DARWIN true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
|
||||
if(NOT OS_LINUX
|
||||
AND NOT OS_FREEBSD
|
||||
AND NOT OS_OPENBSD
|
||||
AND NOT OS_DRAGONFLY
|
||||
AND NOT OS_SOLARIS
|
||||
AND NOT OS_HAIKU
|
||||
AND NOT OS_DARWIN)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Your platform, '${CMAKE_SYSTEM_NAME}', is not currently supported. Patches are welcome."
|
||||
)
|
||||
endif(NOT
|
||||
OS_LINUX
|
||||
AND
|
||||
NOT
|
||||
OS_FREEBSD
|
||||
AND
|
||||
NOT
|
||||
OS_OPENBSD
|
||||
AND
|
||||
NOT
|
||||
OS_DRAGONFLY
|
||||
AND
|
||||
NOT
|
||||
OS_SOLARIS
|
||||
AND
|
||||
NOT
|
||||
OS_HAIKU
|
||||
AND
|
||||
NOT
|
||||
OS_DARWIN)
|
||||
|
||||
include(FindThreads)
|
||||
find_package(Threads)
|
||||
|
||||
set(conky_libs ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(conky_includes ${CMAKE_BINARY_DIR})
|
||||
|
||||
#
|
||||
# On Darwin _POSIX_C_SOURCE must be >= __DARWIN_C_FULL for asprintf to be
|
||||
# enabled! Thus disable this and _LARGEFILE64_SOURCE isnt needed, it is already
|
||||
# used on macOS.
|
||||
#
|
||||
if(NOT OS_DARWIN)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L) # Standard definitions
|
||||
set(
|
||||
CMAKE_REQUIRED_DEFINITIONS
|
||||
"${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L"
|
||||
)
|
||||
endif(NOT OS_DARWIN)
|
||||
|
||||
if(OS_FREEBSD)
|
||||
add_definitions(-D__BSD_VISIBLE=1 -D_XOPEN_SOURCE=700)
|
||||
set(
|
||||
CMAKE_REQUIRED_DEFINITIONS
|
||||
"${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L -D__BSD_VISIBLE=1 -D_XOPEN_SOURCE=700"
|
||||
)
|
||||
endif(OS_FREEBSD)
|
||||
|
||||
if(OS_DRAGONFLY)
|
||||
set(conky_libs ${conky_libs} -L/usr/pkg/lib)
|
||||
set(conky_includes ${conky_includes} -I/usr/pkg/include)
|
||||
endif(OS_DRAGONFLY)
|
||||
|
||||
if(OS_SOLARIS)
|
||||
set(conky_libs ${conky_libs} -L/usr/local/lib)
|
||||
endif(OS_SOLARIS)
|
||||
|
||||
if(OS_HAIKU)
|
||||
# For asprintf
|
||||
add_definitions(-D_GNU_SOURCE) # Standard definitions
|
||||
set(
|
||||
CMAKE_REQUIRED_DEFINITIONS
|
||||
"${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE"
|
||||
)
|
||||
endif(OS_HAIKU)
|
||||
|
||||
# Do version stuff
|
||||
set(VERSION_MAJOR "1")
|
||||
set(VERSION_MINOR "21")
|
||||
set(VERSION_PATCH "3")
|
||||
|
||||
find_program(APP_AWK awk)
|
||||
|
||||
if(NOT APP_AWK)
|
||||
message(FATAL_ERROR "Unable to find program 'awk'")
|
||||
endif(NOT APP_AWK)
|
||||
|
||||
find_program(APP_WC wc)
|
||||
|
||||
if(NOT APP_WC)
|
||||
message(FATAL_ERROR "Unable to find program 'wc'")
|
||||
endif(NOT APP_WC)
|
||||
|
||||
find_program(APP_UNAME uname)
|
||||
|
||||
if(NOT APP_UNAME)
|
||||
message(FATAL_ERROR "Unable to find program 'uname'")
|
||||
endif(NOT APP_UNAME)
|
||||
|
||||
if(NOT RELEASE)
|
||||
find_program(APP_GIT git)
|
||||
|
||||
if(NOT APP_GIT)
|
||||
message(FATAL_ERROR "Unable to find program 'git'")
|
||||
endif(NOT APP_GIT)
|
||||
|
||||
mark_as_advanced(APP_GIT)
|
||||
endif(NOT RELEASE)
|
||||
|
||||
mark_as_advanced(APP_AWK APP_WC APP_UNAME)
|
||||
|
||||
execute_process(COMMAND ${APP_UNAME} -sm
|
||||
RESULT_VARIABLE RETVAL
|
||||
OUTPUT_VARIABLE BUILD_ARCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(COMMAND ${APP_GIT} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
RESULT_VARIABLE RETVAL
|
||||
OUTPUT_VARIABLE GIT_SHORT_SHA
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
set(RELEASE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
|
||||
if(RELEASE)
|
||||
set(VERSION ${RELEASE_VERSION})
|
||||
else(RELEASE)
|
||||
set(VERSION
|
||||
"${RELEASE_VERSION}-pre-${GIT_SHORT_SHA}")
|
||||
endif(RELEASE)
|
||||
|
||||
set(COPYRIGHT "Copyright Brenden Matthews, et al, 2005-2024")
|
||||
|
||||
macro(AC_SEARCH_LIBS FUNCTION_NAME INCLUDES TARGET_VAR)
|
||||
if("${TARGET_VAR}" MATCHES "^${TARGET_VAR}$")
|
||||
unset(AC_SEARCH_LIBS_TMP CACHE)
|
||||
check_symbol_exists(${FUNCTION_NAME} ${INCLUDES} AC_SEARCH_LIBS_TMP)
|
||||
|
||||
if(${AC_SEARCH_LIBS_TMP})
|
||||
set(${TARGET_VAR} "" CACHE INTERNAL "Library containing ${FUNCTION_NAME}")
|
||||
else(${AC_SEARCH_LIBS_TMP})
|
||||
foreach(LIB ${ARGN})
|
||||
unset(AC_SEARCH_LIBS_TMP CACHE)
|
||||
unset(AC_SEARCH_LIBS_FOUND CACHE)
|
||||
find_library(AC_SEARCH_LIBS_TMP ${LIB})
|
||||
check_library_exists(${LIB}
|
||||
${FUNCTION_NAME}
|
||||
${AC_SEARCH_LIBS_TMP}
|
||||
AC_SEARCH_LIBS_FOUND)
|
||||
|
||||
if(${AC_SEARCH_LIBS_FOUND})
|
||||
set(${TARGET_VAR} ${AC_SEARCH_LIBS_TMP}
|
||||
CACHE INTERNAL "Library containing ${FUNCTION_NAME}")
|
||||
break()
|
||||
endif(${AC_SEARCH_LIBS_FOUND})
|
||||
endforeach(LIB)
|
||||
endif(${AC_SEARCH_LIBS_TMP})
|
||||
endif("${TARGET_VAR}" MATCHES "^${TARGET_VAR}$")
|
||||
endmacro(AC_SEARCH_LIBS)
|
||||
|
||||
# A function to print the target build properties
|
||||
function(print_target_properties tgt)
|
||||
if(NOT TARGET ${tgt})
|
||||
message("There is no target named '${tgt}'")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# this list of properties can be extended as needed
|
||||
set(CMAKE_PROPERTY_LIST
|
||||
SOURCE_DIR
|
||||
BINARY_DIR
|
||||
COMPILE_DEFINITIONS
|
||||
COMPILE_OPTIONS
|
||||
INCLUDE_DIRECTORIES
|
||||
LINK_LIBRARIES)
|
||||
|
||||
message("Configuration for target ${tgt}")
|
||||
|
||||
foreach(prop ${CMAKE_PROPERTY_LIST})
|
||||
get_property(propval TARGET ${tgt} PROPERTY ${prop} SET)
|
||||
|
||||
if(propval)
|
||||
get_target_property(propval ${tgt} ${prop})
|
||||
message(STATUS "${prop} = ${propval}")
|
||||
endif()
|
||||
endforeach(prop)
|
||||
endfunction(print_target_properties)
|
||||
292
cmake/ConkyBuildOptions.cmake
Normal file
292
cmake/ConkyBuildOptions.cmake
Normal file
|
|
@ -0,0 +1,292 @@
|
|||
#
|
||||
# Conky, a system monitor, based on torsmo
|
||||
#
|
||||
# Please see COPYING for details
|
||||
#
|
||||
# Copyright (c) 2005-2024 Brenden Matthews, et. al. (see AUTHORS) All rights
|
||||
# reserved.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details. You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
include(CMakeDependentOption)
|
||||
include(DependentOption)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
if(MAINTAINER_MODE)
|
||||
set(
|
||||
CMAKE_BUILD_TYPE Debug
|
||||
CACHE
|
||||
STRING
|
||||
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
||||
FORCE)
|
||||
else(MAINTAINER_MODE)
|
||||
set(
|
||||
CMAKE_BUILD_TYPE RelWithDebInfo
|
||||
CACHE
|
||||
STRING
|
||||
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
||||
FORCE)
|
||||
endif(MAINTAINER_MODE)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
# -std options for all build types
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if(MAINTAINER_MODE)
|
||||
set(CMAKE_COMPILE_WARNING_AS_ERROR true)
|
||||
set(BUILD_TESTS true)
|
||||
endif(MAINTAINER_MODE)
|
||||
|
||||
# Always use libc++ when compiling w/ clang
|
||||
add_compile_options(
|
||||
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-stdlib=libc++>
|
||||
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-Wno-unknown-warning-option>
|
||||
$<$<COMPILE_LANG_AND_ID:CXX,GCC>:-Wno-unknown-warning>)
|
||||
add_link_options($<$<COMPILE_LANG_AND_ID:CXX,Clang>:-stdlib=libc++>)
|
||||
|
||||
option(CHECK_CODE_QUALITY "Check code formatting/quality with clang" false)
|
||||
|
||||
option(RELEASE "Build release package" false)
|
||||
mark_as_advanced(RELEASE)
|
||||
|
||||
option(MAINTAINER_MODE "Enable maintainer mode" false)
|
||||
option(CODE_COVERAGE "Enable code coverage report generation" false)
|
||||
|
||||
option(BUILD_DOCS "Build documentation" false)
|
||||
option(BUILD_EXTRAS "Build extras (includes syntax files for editors)" false)
|
||||
|
||||
option(BUILD_I18N "Enable if you want internationalization support" true)
|
||||
|
||||
option(BUILD_COLOUR_NAME_MAP "Include mappings of colour name -> RGB (i.e., red -> ff0000)" true)
|
||||
|
||||
if(BUILD_I18N)
|
||||
set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale"
|
||||
CACHE STRING "Directory containing the locales")
|
||||
endif(BUILD_I18N)
|
||||
|
||||
# Some standard options
|
||||
set(SYSTEM_CONFIG_FILE "/etc/conky/conky.conf"
|
||||
CACHE STRING "Default system-wide Conky configuration file")
|
||||
|
||||
# use FORCE below to make sure this changes when CMAKE_INSTALL_PREFIX is
|
||||
# modified
|
||||
if(NOT LIB_INSTALL_DIR)
|
||||
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
|
||||
endif(NOT LIB_INSTALL_DIR)
|
||||
|
||||
set(PACKAGE_LIBRARY_DIR "${LIB_INSTALL_DIR}/conky"
|
||||
CACHE STRING "Package library path (where Lua bindings are installed"
|
||||
FORCE)
|
||||
set(DEFAULTNETDEV "eno1" CACHE STRING "Default networkdevice")
|
||||
|
||||
# Mac only override
|
||||
if(OS_DARWIN)
|
||||
set(DEFAULTNETDEV "en0" CACHE STRING "Default networkdevice" FORCE)
|
||||
endif(OS_DARWIN)
|
||||
|
||||
set(XDG_CONFIG_FILE "$HOME/.config/conky/conky.conf"
|
||||
CACHE STRING "Configfile of the user (XDG)")
|
||||
set(CONFIG_FILE "$HOME/.conkyrc" CACHE STRING "Configfile of the user")
|
||||
set(MAX_USER_TEXT_DEFAULT "16384"
|
||||
CACHE STRING
|
||||
"Default maximum size of config TEXT buffer, i.e. below TEXT line.")
|
||||
set(DEFAULT_TEXT_BUFFER_SIZE "256"
|
||||
CACHE STRING "Default size used for temporary, static text buffers")
|
||||
set(MAX_NET_INTERFACES "256" CACHE STRING "Maximum number of network devices")
|
||||
|
||||
# Platform specific options Linux only
|
||||
cmake_dependent_option(BUILD_PORT_MONITORS "Build TCP portmon support" true
|
||||
"OS_LINUX" false)
|
||||
cmake_dependent_option(BUILD_IBM "Support for IBM/Lenovo notebooks" true
|
||||
"OS_LINUX" false)
|
||||
cmake_dependent_option(BUILD_HDDTEMP "Support for hddtemp" true
|
||||
"OS_LINUX" false)
|
||||
cmake_dependent_option(BUILD_IPV6 "Enable if you want IPv6 support" true
|
||||
"OS_LINUX" false)
|
||||
|
||||
if(OS_LINUX)
|
||||
# nvidia may also work on FreeBSD, not sure
|
||||
# NvCtrl requires X11. Should be modified to use NVML directly.
|
||||
dependent_option(BUILD_NVIDIA "Enable Nvidia NvCtrl variables" false
|
||||
"BUILD_X11" false
|
||||
"Nvidia NvCtrl variables require X11")
|
||||
else()
|
||||
set(BUILD_NVIDIA false CACHE BOOL "Enable Nvidia NvCtrl variables" FORCE)
|
||||
endif(OS_LINUX)
|
||||
|
||||
# macOS Only
|
||||
cmake_dependent_option(
|
||||
BUILD_IPGFREQ
|
||||
"Enable cpu freq calculation based on Intel® Power Gadget; otherwise use constant factory value"
|
||||
false
|
||||
"OS_DARWIN" false)
|
||||
|
||||
# Optional features etc
|
||||
option(BUILD_WLAN "Enable wireless support" false)
|
||||
|
||||
option(BUILD_BUILTIN_CONFIG "Enable builtin default configuration" true)
|
||||
|
||||
option(BUILD_IOSTATS "Enable disk I/O stats" true)
|
||||
|
||||
option(BUILD_OLD_CONFIG "Enable support for the old syntax of configurations"
|
||||
true)
|
||||
|
||||
option(BUILD_MATH "Enable math support" true)
|
||||
|
||||
option(BUILD_NCURSES "Enable ncurses support" true)
|
||||
|
||||
dependent_option(LEAKFREE_NCURSES
|
||||
"Enable to hide false ncurses-memleaks in valgrind (works only when ncurses is compiled with --disable-leaks)"
|
||||
false
|
||||
"BUILD_NCURSES" false
|
||||
"LEAKFREE_NCURSES requires ncurses")
|
||||
|
||||
option(BUILD_WAYLAND "Build Wayland support" false)
|
||||
|
||||
option(BUILD_X11 "Build X11 support" true)
|
||||
|
||||
dependent_option(OWN_WINDOW "Enable running conky in a dedicated window" true
|
||||
"BUILD_X11" false
|
||||
"Dedicated window mode only works on X11")
|
||||
|
||||
# On MacOS these cause issues so they're disabled by default
|
||||
if(OS_DARWIN)
|
||||
dependent_option(BUILD_XDAMAGE "Build Xdamage support" false
|
||||
"BUILD_X11" false
|
||||
"Xdamage support requires X11")
|
||||
dependent_option(BUILD_XFIXES "Build Xfixes support" false
|
||||
"BUILD_X11" false
|
||||
"Xfixes support requires X11")
|
||||
else()
|
||||
dependent_option(BUILD_XDAMAGE "Build Xdamage support" true
|
||||
"BUILD_X11" false
|
||||
"Xdamage support requires X11")
|
||||
dependent_option(BUILD_XFIXES "Build Xfixes support" true
|
||||
"BUILD_X11" false
|
||||
"Xfixes support requires X11")
|
||||
endif(OS_DARWIN)
|
||||
|
||||
dependent_option(BUILD_ARGB "Build ARGB (real transparency) support" true
|
||||
"BUILD_X11;OWN_WINDOW" false
|
||||
"ARGB support requires X11 and OWN_WINDOW enabled, not needed on Wayland")
|
||||
dependent_option(BUILD_XINERAMA "Build Xinerama support" true
|
||||
"BUILD_X11" false
|
||||
"Xinerama support requires X11")
|
||||
dependent_option(BUILD_XDBE "Build Xdbe (double-buffer) support" true
|
||||
"BUILD_X11" false
|
||||
"Xdbe based double-buffering requires X11")
|
||||
dependent_option(BUILD_XFT "Build Xft (freetype fonts) support" true
|
||||
"BUILD_X11" false
|
||||
"Xft (freetype font) support requires X11")
|
||||
dependent_option(BUILD_IMLIB2 "Enable Imlib2 support" true
|
||||
"BUILD_X11" false
|
||||
"Imlib2 support requires X11")
|
||||
dependent_option(BUILD_XSHAPE "Enable Xshape support" true
|
||||
"BUILD_X11" false
|
||||
"Xshape support requires X11")
|
||||
dependent_option(BUILD_XINPUT "Build Xinput 2 support (slow)" false
|
||||
"BUILD_X11" false
|
||||
"Xinput 2 support requires X11")
|
||||
|
||||
# if we build with any GUI support
|
||||
if(BUILD_X11)
|
||||
set(BUILD_GUI true)
|
||||
endif(BUILD_X11)
|
||||
|
||||
if(BUILD_WAYLAND)
|
||||
set(BUILD_GUI true)
|
||||
endif(BUILD_WAYLAND)
|
||||
|
||||
dependent_option(BUILD_MOUSE_EVENTS "Enable mouse event support" true
|
||||
"BUILD_WAYLAND OR BUILD_X11" false
|
||||
"Mouse event support requires Wayland or X11 enabled")
|
||||
|
||||
# Lua library options
|
||||
dependent_option(BUILD_LUA_CAIRO "Build Cairo bindings for Lua" false
|
||||
"BUILD_GUI" false
|
||||
"Cairo Lua bindings depend on BUILD_GUI")
|
||||
dependent_option(BUILD_LUA_CAIRO_XLIB "Build Cairo & Xlib interoperability for Lua" true
|
||||
"BUILD_X11;BUILD_LUA_CAIRO" false
|
||||
"Cairo Xlib Lua bindings require Cairo and X11")
|
||||
dependent_option(BUILD_LUA_IMLIB2 "Build Imlib2 bindings for Lua" false
|
||||
"BUILD_X11;BUILD_IMLIB2" false
|
||||
"Imlib2 Lua bindings require X11 and Imlib2")
|
||||
dependent_option(BUILD_LUA_RSVG "Build rsvg bindings for Lua" false
|
||||
"BUILD_GUI" false
|
||||
"RSVG Lua bindings depend on BUILD_GUI")
|
||||
|
||||
option(BUILD_AUDACIOUS "Build audacious (music player) support" false)
|
||||
|
||||
option(BUILD_MPD "Enable if you want MPD (music player) support" true)
|
||||
|
||||
option(BUILD_MYSQL "Enable if you want MySQL support" false)
|
||||
|
||||
option(BUILD_MOC "Enable if you want MOC (music player) support" true)
|
||||
|
||||
option(BUILD_XMMS2 "Enable if you want XMMS2 (music player) support" false)
|
||||
|
||||
option(BUILD_CURL "Enable if you want Curl support" false)
|
||||
|
||||
dependent_option(BUILD_RSS "Enable if you want RSS support" false
|
||||
"BUILD_CURL" false
|
||||
"RSS depends on Curl support")
|
||||
|
||||
option(BUILD_APCUPSD "Enable APCUPSD support" true)
|
||||
|
||||
option(BUILD_ICAL "Enable if you want iCalendar (RFC 5545) support" false)
|
||||
|
||||
option(BUILD_IRC "Enable if you want IRC support" false)
|
||||
|
||||
option(BUILD_HTTP "Enable if you want HTTP support" false)
|
||||
|
||||
if(NOT BUILD_HTTP)
|
||||
set(HTTPPORT "10080" CACHE STRING "Port to use for out_to_http")
|
||||
else(NOT BUILD_HTTP)
|
||||
set(HTTPPORT "10080")
|
||||
endif(NOT BUILD_HTTP)
|
||||
|
||||
option(BUILD_ICONV "Enable iconv support" false)
|
||||
|
||||
option(BUILD_CMUS "Enable support for cmus music player" true)
|
||||
|
||||
option(BUILD_JOURNAL "Enable support for reading from the systemd journal"
|
||||
false)
|
||||
|
||||
option(BUILD_PULSEAUDIO
|
||||
"Enable support for Pulseaudio's default sink and source" false)
|
||||
|
||||
option(BUILD_INTEL_BACKLIGHT
|
||||
"Enable support for Intel backlight" false)
|
||||
|
||||
run_dependency_checks()
|
||||
|
||||
message(STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS})
|
||||
message(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
|
||||
|
||||
message(STATUS "CMAKE_C_FLAGS_DEBUG: " ${CMAKE_C_FLAGS_DEBUG})
|
||||
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: " ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
|
||||
message(STATUS "CMAKE_C_FLAGS_MINSIZEREL: " ${CMAKE_C_FLAGS_MINSIZEREL})
|
||||
message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL: " ${CMAKE_CXX_FLAGS_MINSIZEREL})
|
||||
|
||||
message(STATUS "CMAKE_C_FLAGS_RELEASE: " ${CMAKE_C_FLAGS_RELEASE})
|
||||
message(STATUS "CMAKE_CXX_FLAGS_RELEASE: " ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
|
||||
message(STATUS "CMAKE_C_FLAGS_RELWITHDEBINFO: " ${CMAKE_C_FLAGS_RELWITHDEBINFO})
|
||||
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: "
|
||||
${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
|
||||
|
||||
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
|
||||
67
cmake/ConkyCPackSetup.cmake
Normal file
67
cmake/ConkyCPackSetup.cmake
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#
|
||||
# Conky, a system monitor, based on torsmo
|
||||
#
|
||||
# Please see COPYING for details
|
||||
#
|
||||
# Copyright (c) 2005-2024 Brenden Matthews, et. al. (see AUTHORS) All rights
|
||||
# reserved.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details. You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
set(CPACK_GENERATOR "TGZ;STGZ;DEB")
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>=2.10-1), libgcc1 (>= 1:4.4.0)")
|
||||
set(CPACK_PACKAGE_CONTACT "brenden@diddyinc.com")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Brenden Matthews")
|
||||
set(CPACK_PACKAGE_FILE_NAME
|
||||
"${PROJECT_NAME}-${VERSION}-${CMAKE_SYSTEM_NAME}-${CPU_ARCH}")
|
||||
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_NAME})
|
||||
|
||||
set(CPACK_STRIP_FILES true)
|
||||
|
||||
# Version numbering, copyright notice, etc. are taken from the variables defined
|
||||
# in ../CMakeLists.txt.
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
|
||||
|
||||
if(CPACK_GENERATOR MATCHES "NSIS")
|
||||
set(CPACK_NSIS_COMPRESSOR "/FINAL /SOLID lzma")
|
||||
set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME} ${PROJECT_NAME})
|
||||
endif(CPACK_GENERATOR MATCHES "NSIS")
|
||||
|
||||
# Source package setup. Compile with "make package_source".
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION}-src")
|
||||
set(CPACK_SOURCE_GENERATOR "TBZ2")
|
||||
execute_process(COMMAND ${APP_UNAME}
|
||||
COMMAND ${APP_AWK} "{print $1}"
|
||||
RESULT_VARIABLE RETVAL
|
||||
OUTPUT_VARIABLE CPU_ARCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
|
||||
# Exclude backup files generated by text editors.
|
||||
"~$"
|
||||
|
||||
# Git dir/files.
|
||||
"\\\\.git.*$"
|
||||
|
||||
# vim swap files
|
||||
"\\\\..*\\\\.swp$"
|
||||
|
||||
# Build dir.
|
||||
"build.*$")
|
||||
|
||||
# Enable CPack
|
||||
include(CPack)
|
||||
697
cmake/ConkyPlatformChecks.cmake
Normal file
697
cmake/ConkyPlatformChecks.cmake
Normal file
|
|
@ -0,0 +1,697 @@
|
|||
#
|
||||
# Conky, a system monitor, based on torsmo
|
||||
#
|
||||
# Please see COPYING for details
|
||||
#
|
||||
# Copyright (c) 2005-2024 Brenden Matthews, et. al. (see AUTHORS) All rights
|
||||
# reserved.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details. You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
include(FindPkgConfig)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckSymbolExists)
|
||||
|
||||
# Check for some headers
|
||||
check_include_files(sys/statfs.h HAVE_SYS_STATFS_H)
|
||||
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
|
||||
check_include_files(sys/inotify.h HAVE_SYS_INOTIFY_H)
|
||||
check_include_files(dirent.h HAVE_DIRENT_H)
|
||||
|
||||
# Check for some functions
|
||||
check_function_exists(strndup HAVE_STRNDUP)
|
||||
|
||||
check_symbol_exists(pipe2 "unistd.h" HAVE_PIPE2)
|
||||
check_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
check_symbol_exists(statfs64 "sys/mount.h" HAVE_STATFS64)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
check_symbol_exists(statfs64 "sys/statfs.h" HAVE_STATFS64)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
|
||||
ac_search_libs(clock_gettime "time.h" CLOCK_GETTIME_LIB "rt")
|
||||
|
||||
if(NOT DEFINED CLOCK_GETTIME_LIB)
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
message(FATAL_ERROR "clock_gettime not found.")
|
||||
endif(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
else(NOT DEFINED CLOCK_GETTIME_LIB)
|
||||
set(HAVE_CLOCK_GETTIME 1)
|
||||
endif(NOT DEFINED CLOCK_GETTIME_LIB)
|
||||
|
||||
set(conky_libs ${conky_libs} ${CLOCK_GETTIME_LIB})
|
||||
|
||||
# standard path to search for includes
|
||||
set(INCLUDE_SEARCH_PATH /usr/include /usr/local/include)
|
||||
|
||||
# Set system vars
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(OS_LINUX true)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(OS_LINUX false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
set(OS_FREEBSD true)
|
||||
set(conky_libs ${conky_libs} -lkvm -ldevstat -lintl -linotify)
|
||||
|
||||
if(BUILD_IRC)
|
||||
set(conky_libs ${conky_libs} -lssl -lcrypto)
|
||||
endif(BUILD_IRC)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
set(OS_FREEBSD false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
set(OS_DRAGONFLY true)
|
||||
set(conky_libs ${conky_libs} -ldevstat)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
set(OS_DRAGONFLY false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
set(OS_OPENBSD true)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
set(OS_OPENBSD false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
set(OS_SOLARIS true)
|
||||
set(conky_libs ${conky_libs} -lkstat)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
set(OS_SOLARIS false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
set(OS_NETBSD true)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
set(OS_NETBSD false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||
set(OS_HAIKU true)
|
||||
set(conky_libs ${conky_libs} -lnetwork -lintl)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||
set(OS_HAIKU false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(OS_DARWIN true)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(OS_DARWIN false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
|
||||
if(NOT OS_LINUX
|
||||
AND NOT OS_FREEBSD
|
||||
AND NOT OS_OPENBSD
|
||||
AND NOT OS_DRAGONFLY
|
||||
AND NOT OS_SOLARIS
|
||||
AND NOT OS_HAIKU
|
||||
AND NOT OS_DARWIN)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Your platform, '${CMAKE_SYSTEM_NAME}', is not currently supported. Patches are welcome."
|
||||
)
|
||||
endif(NOT
|
||||
OS_LINUX
|
||||
AND
|
||||
NOT
|
||||
OS_FREEBSD
|
||||
AND
|
||||
NOT
|
||||
OS_OPENBSD
|
||||
AND
|
||||
NOT
|
||||
OS_DRAGONFLY
|
||||
AND
|
||||
NOT
|
||||
OS_SOLARIS
|
||||
AND
|
||||
NOT
|
||||
OS_HAIKU
|
||||
AND
|
||||
NOT
|
||||
OS_DARWIN)
|
||||
|
||||
# Check for soundcard header
|
||||
if(OS_LINUX)
|
||||
check_include_files("linux/soundcard.h" HAVE_SOME_SOUNDCARD_H)
|
||||
check_include_files("linux/soundcard.h" HAVE_LINUX_SOUNDCARD_H)
|
||||
check_include_files("linux/sockios.h" HAVE_LINUX_SOCKIOS_H)
|
||||
elseif(OS_OPENBSD)
|
||||
check_include_files("soundcard.h" HAVE_SOME_SOUNDCARD_H)
|
||||
else(OS_LINUX)
|
||||
check_include_files("sys/soundcard.h" HAVE_SOME_SOUNDCARD_H)
|
||||
endif(OS_LINUX)
|
||||
|
||||
if(BUILD_I18N AND OS_DRAGONFLY)
|
||||
set(conky_libs ${conky_libs} -lintl)
|
||||
endif(BUILD_I18N AND OS_DRAGONFLY)
|
||||
|
||||
if(BUILD_I18N AND OS_DARWIN)
|
||||
find_path(LIBINTL_H_N libintl.h
|
||||
PATHS /usr/local/opt/gettext/include
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/usr/local/opt/include)
|
||||
|
||||
if(LIBINTL_H_N)
|
||||
include_directories(${LIBINTL_H_N})
|
||||
else(LIBINTL_H_N)
|
||||
message(FATAL_ERROR "Unable to find libintl.h (try `brew install gettext`)")
|
||||
endif(LIBINTL_H_N)
|
||||
|
||||
find_library(INTL_LIB
|
||||
NAMES intl
|
||||
PATHS /usr/local/opt/gettext/lib
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/usr/local/opt/lib)
|
||||
set(conky_libs ${conky_libs} ${INTL_LIB})
|
||||
endif(BUILD_I18N AND OS_DARWIN)
|
||||
|
||||
if(BUILD_NCURSES AND OS_DARWIN)
|
||||
set(conky_libs ${conky_libs} -lncurses)
|
||||
endif(BUILD_NCURSES AND OS_DARWIN)
|
||||
|
||||
if(BUILD_WLAN AND OS_DARWIN)
|
||||
find_library(CW CoreWLAN)
|
||||
find_library(NS Foundation)
|
||||
set(conky_libs ${conky_libs} ${CW})
|
||||
set(conky_libs ${conky_libs} ${NS})
|
||||
endif(BUILD_WLAN AND OS_DARWIN)
|
||||
|
||||
if(OS_DARWIN AND BUILD_IPGFREQ)
|
||||
find_library(IPG IntelPowerGadget)
|
||||
set(conky_libs ${conky_libs} ${IPG})
|
||||
endif(OS_DARWIN AND BUILD_IPGFREQ)
|
||||
|
||||
if(BUILD_MATH)
|
||||
set(conky_libs ${conky_libs} -lm)
|
||||
endif(BUILD_MATH)
|
||||
|
||||
if(BUILD_ICAL)
|
||||
check_include_files(libical/ical.h ICAL_H_)
|
||||
|
||||
if(NOT ICAL_H_)
|
||||
message(FATAL_ERROR "Unable to find libical")
|
||||
endif(NOT ICAL_H_)
|
||||
|
||||
set(conky_libs ${conky_libs} -lical)
|
||||
endif(BUILD_ICAL)
|
||||
|
||||
if(BUILD_IRC)
|
||||
find_path(IRC_H_N libircclient.h PATHS /usr/include/libircclient)
|
||||
find_path(IRC_H_S libircclient.h PATHS /usr/include)
|
||||
|
||||
if(IRC_H_N)
|
||||
include_directories(${IRC_H_N})
|
||||
endif(IRC_H_N)
|
||||
|
||||
if(IRC_H_N OR IRC_H_S)
|
||||
set(IRC_H_ true)
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to find libircclient")
|
||||
endif(IRC_H_N OR IRC_H_S)
|
||||
|
||||
set(conky_libs ${conky_libs} -lircclient)
|
||||
endif(BUILD_IRC)
|
||||
|
||||
if(BUILD_IPV6)
|
||||
find_file(IF_INET6 if_inet6 PATHS /proc/net)
|
||||
|
||||
if(NOT IF_INET6)
|
||||
message(WARNING "/proc/net/if_inet6 unavailable")
|
||||
endif(NOT IF_INET6)
|
||||
endif(BUILD_IPV6)
|
||||
|
||||
if(BUILD_HTTP)
|
||||
pkg_check_modules(MICROHTTPD REQUIRED libmicrohttpd>=0.9.25)
|
||||
set(conky_libs ${conky_libs} ${MICROHTTPD_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${MICROHTTPD_INCLUDE_DIRS})
|
||||
endif(BUILD_HTTP)
|
||||
|
||||
if(BUILD_NCURSES)
|
||||
set(CURSES_NEED_NCURSES TRUE)
|
||||
include(FindCurses)
|
||||
|
||||
if(NOT CURSES_FOUND)
|
||||
message(FATAL_ERROR "Unable to find ncurses library")
|
||||
endif(NOT CURSES_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${CURSES_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${CURSES_INCLUDE_DIR})
|
||||
endif(BUILD_NCURSES)
|
||||
|
||||
if(BUILD_MYSQL)
|
||||
find_path(mysql_INCLUDE_PATH
|
||||
mysql.h
|
||||
${INCLUDE_SEARCH_PATH}
|
||||
/usr/include/mysql
|
||||
/usr/local/include/mysql)
|
||||
|
||||
if(NOT mysql_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "Unable to find mysql.h")
|
||||
endif(NOT mysql_INCLUDE_PATH)
|
||||
|
||||
set(conky_includes ${conky_includes} ${mysql_INCLUDE_PATH})
|
||||
find_library(MYSQLCLIENT_LIB
|
||||
NAMES mysqlclient
|
||||
PATHS /usr/lib
|
||||
/usr/lib64
|
||||
/usr/lib/mysql
|
||||
/usr/lib64/mysql
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/local/lib/mysql
|
||||
/usr/local/lib64/mysql)
|
||||
|
||||
if(NOT MYSQLCLIENT_LIB)
|
||||
message(FATAL_ERROR "Unable to find mysqlclient library")
|
||||
endif(NOT MYSQLCLIENT_LIB)
|
||||
|
||||
set(conky_libs ${conky_libs} ${MYSQLCLIENT_LIB})
|
||||
endif(BUILD_MYSQL)
|
||||
|
||||
if(BUILD_WLAN AND OS_LINUX)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
||||
check_include_files(iwlib.h IWLIB_H)
|
||||
|
||||
if(NOT IWLIB_H)
|
||||
message(FATAL_ERROR "Unable to find iwlib.h")
|
||||
endif(NOT IWLIB_H)
|
||||
|
||||
find_library(IWLIB_LIB NAMES iw)
|
||||
|
||||
if(NOT IWLIB_LIB)
|
||||
message(FATAL_ERROR "Unable to find libiw.so")
|
||||
endif(NOT IWLIB_LIB)
|
||||
|
||||
set(conky_libs ${conky_libs} ${IWLIB_LIB})
|
||||
check_function_exists(iw_sockets_open IWLIB_SOCKETS_OPEN_FUNC)
|
||||
endif(BUILD_WLAN AND OS_LINUX)
|
||||
|
||||
if(BUILD_PORT_MONITORS)
|
||||
check_function_exists(getnameinfo HAVE_GETNAMEINFO)
|
||||
|
||||
if(NOT HAVE_GETNAMEINFO)
|
||||
message(FATAL_ERROR "could not find getnameinfo()")
|
||||
endif(NOT HAVE_GETNAMEINFO)
|
||||
|
||||
check_include_files(
|
||||
"netdb.h;netinet/in.h;netinet/tcp.h;sys/socket.h;arpa/inet.h"
|
||||
HAVE_PORTMON_HEADERS)
|
||||
|
||||
if(NOT HAVE_PORTMON_HEADERS)
|
||||
message(FATAL_ERROR "missing needed network header(s) for port monitoring")
|
||||
endif(NOT HAVE_PORTMON_HEADERS)
|
||||
endif(BUILD_PORT_MONITORS)
|
||||
|
||||
# Check for iconv
|
||||
if(BUILD_ICONV)
|
||||
check_include_files(iconv.h HAVE_ICONV_H)
|
||||
find_library(ICONV_LIBRARY NAMES iconv)
|
||||
|
||||
if(NOT ICONV_LIBRARY)
|
||||
# maybe iconv() is provided by libc
|
||||
set(ICONV_LIBRARY ""
|
||||
CACHE FILEPATH
|
||||
"Path to the iconv library, if iconv is not provided by libc"
|
||||
FORCE)
|
||||
endif(NOT ICONV_LIBRARY)
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
|
||||
check_function_exists(iconv ICONV_FUNC)
|
||||
|
||||
if(HAVE_ICONV_H AND ICONV_FUNC)
|
||||
set(conky_includes ${conky_includes} ${ICONV_INCLUDE_DIR})
|
||||
set(conky_libs ${conky_libs} ${ICONV_LIBRARY})
|
||||
else(HAVE_ICONV_H AND ICONV_FUNC)
|
||||
message(FATAL_ERROR "Unable to find iconv library")
|
||||
endif(HAVE_ICONV_H AND ICONV_FUNC)
|
||||
endif(BUILD_ICONV)
|
||||
|
||||
# check for Xlib
|
||||
if(BUILD_X11)
|
||||
include(FindX11)
|
||||
find_package(X11)
|
||||
|
||||
if(X11_FOUND)
|
||||
set(conky_includes ${conky_includes} ${X11_INCLUDE_DIR})
|
||||
set(conky_libs ${conky_libs} ${X11_LIBRARIES})
|
||||
|
||||
# check for Xdamage
|
||||
if(BUILD_XDAMAGE)
|
||||
if(NOT X11_Xdamage_FOUND)
|
||||
message(FATAL_ERROR "Unable to find Xdamage library")
|
||||
endif(NOT X11_Xdamage_FOUND)
|
||||
|
||||
if(NOT X11_Xfixes_FOUND)
|
||||
message(FATAL_ERROR "Unable to find Xfixes library")
|
||||
endif(NOT X11_Xfixes_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${X11_Xdamage_LIB} ${X11_Xfixes_LIB})
|
||||
endif(BUILD_XDAMAGE)
|
||||
|
||||
if(BUILD_XSHAPE)
|
||||
if(NOT X11_Xshape_FOUND)
|
||||
message(FATAL_ERROR "Unable to find Xshape library")
|
||||
endif(NOT X11_Xshape_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${X11_Xshape_LIB})
|
||||
endif(BUILD_XSHAPE)
|
||||
|
||||
# check for Xft
|
||||
if(BUILD_XFT)
|
||||
if(FREETYPE_INCLUDE_DIR_freetype2)
|
||||
set(FREETYPE_FOUND true)
|
||||
set(conky_includes ${conky_includes} ${FREETYPE_INCLUDE_DIR_freetype2})
|
||||
else(FREETYPE_INCLUDE_DIR_freetype2)
|
||||
message(FATAL_ERROR "Unable to find freetype library")
|
||||
endif(FREETYPE_INCLUDE_DIR_freetype2)
|
||||
|
||||
if(NOT X11_Xft_FOUND)
|
||||
message(FATAL_ERROR "Unable to find Xft library")
|
||||
endif(NOT X11_Xft_FOUND)
|
||||
|
||||
find_package(Fontconfig REQUIRED)
|
||||
|
||||
set(conky_libs ${conky_libs} ${X11_Xft_LIB} ${Fontconfig_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${FREETYPE_INCLUDE_DIR_freetype2} ${Fontconfig_INCLUDE_DIRS})
|
||||
endif(BUILD_XFT)
|
||||
|
||||
# check for Xdbe
|
||||
if(BUILD_XDBE)
|
||||
if(NOT X11_Xext_FOUND)
|
||||
message(FATAL_ERROR "Unable to find Xext library (needed for Xdbe)")
|
||||
endif(NOT X11_Xext_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${X11_Xext_LIB})
|
||||
endif(BUILD_XDBE)
|
||||
|
||||
# check for Xinerama
|
||||
if(BUILD_XINERAMA)
|
||||
if(NOT X11_Xinerama_FOUND)
|
||||
message(FATAL_ERROR "Unable to find Xinerama library")
|
||||
endif(NOT X11_Xinerama_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${X11_Xinerama_LIB})
|
||||
endif(BUILD_XINERAMA)
|
||||
|
||||
# check for Xfixes
|
||||
if(BUILD_XFIXES)
|
||||
if(NOT X11_Xfixes_FOUND)
|
||||
message(FATAL_ERROR "Unable to find Xfixes library")
|
||||
endif(NOT X11_Xfixes_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${X11_Xfixes_LIB})
|
||||
endif(BUILD_XFIXES)
|
||||
|
||||
# check for Xinput
|
||||
if(BUILD_XINPUT)
|
||||
if(NOT X11_Xinput_FOUND)
|
||||
message(FATAL_ERROR "Unable to find Xinput library")
|
||||
endif(NOT X11_Xinput_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${X11_Xinput_LIB})
|
||||
endif(BUILD_XINPUT)
|
||||
|
||||
if(X11_xcb_FOUND)
|
||||
set(HAVE_XCB true)
|
||||
set(conky_libs ${conky_libs} ${X11_xcb_LIB})
|
||||
set(conky_includes ${conky_includes} ${X11_xcb_INCLUDE_PATH})
|
||||
|
||||
if(X11_xcb_errors_FOUND)
|
||||
set(HAVE_XCB_ERRORS true)
|
||||
set(conky_libs ${conky_libs} ${X11_xcb_LIB} ${X11_xcb_errors_LIB})
|
||||
else(X11_xcb_errors_FOUND)
|
||||
set(HAVE_XCB_ERRORS false)
|
||||
endif(X11_xcb_errors_FOUND)
|
||||
else(X11_xcb_FOUND)
|
||||
set(HAVE_XCB false)
|
||||
endif(X11_xcb_FOUND)
|
||||
else(X11_FOUND)
|
||||
message(FATAL_ERROR "Unable to find X11 library")
|
||||
endif(X11_FOUND)
|
||||
endif(BUILD_X11)
|
||||
|
||||
if(BUILD_WAYLAND)
|
||||
find_package(Wayland REQUIRED)
|
||||
set(conky_libs ${conky_libs} ${Wayland_CLIENT_LIBRARY})
|
||||
set(conky_includes ${conky_includes} ${Wayland_CLIENT_INCLUDE_DIR})
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
pkg_check_modules(wayland-protocols QUIET wayland-protocols>=1.13)
|
||||
|
||||
if(Wayland_FOUND AND wayland-protocols_FOUND)
|
||||
# find Wayland protocols
|
||||
pkg_get_variable(Wayland_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
||||
|
||||
# find 'wayland-scanner' executable
|
||||
pkg_get_variable(Wayland_SCANNER wayland-scanner wayland_scanner)
|
||||
else(Wayland_FOUND AND wayland-protocols_FOUND)
|
||||
message(FATAL_ERROR "Unable to find wayland-scanner and xdg-shell protocol")
|
||||
endif(Wayland_FOUND AND wayland-protocols_FOUND)
|
||||
|
||||
if(OS_DARWIN OR OS_DRAGONFLY OR OS_FREEBSD OR OS_NETBSD OR OS_OPENBSD)
|
||||
pkg_check_modules(EPOLL REQUIRED epoll-shim)
|
||||
set(conky_libs ${conky_libs} ${EPOLL_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${EPOLL_INCLUDE_DIRS})
|
||||
endif(OS_DARWIN OR OS_DRAGONFLY OR OS_FREEBSD OR OS_NETBSD OR OS_OPENBSD)
|
||||
|
||||
pkg_check_modules(CAIRO REQUIRED cairo)
|
||||
set(conky_libs ${conky_libs} ${CAIRO_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${CAIRO_INCLUDE_DIR})
|
||||
|
||||
pkg_check_modules(PANGO REQUIRED pango)
|
||||
set(conky_libs ${conky_libs} ${PANGO_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${PANGO_INCLUDE_DIRS})
|
||||
|
||||
pkg_check_modules(PANGOCAIRO pangocairo)
|
||||
set(conky_libs ${conky_libs} ${PANGOCAIRO_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${PANGOCAIRO_INCLUDE_DIRS})
|
||||
|
||||
pkg_check_modules(PANGOFC pangofc)
|
||||
set(conky_libs ${conky_libs} ${PANGOFC_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${PANGOFC_INCLUDE_DIRS})
|
||||
|
||||
pkg_check_modules(PANGOFT2 pangoft2)
|
||||
set(conky_libs ${conky_libs} ${PANGOFT2_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${PANGOFT2_INCLUDE_DIRS})
|
||||
endif(BUILD_WAYLAND)
|
||||
|
||||
find_package(Lua "5.3" REQUIRED)
|
||||
|
||||
set(conky_libs ${conky_libs} ${LUA_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${LUA_INCLUDE_DIR})
|
||||
include_directories(3rdparty/toluapp/include)
|
||||
|
||||
# Check for libraries used by Lua bindings
|
||||
if(BUILD_LUA_CAIRO)
|
||||
pkg_check_modules(CAIRO REQUIRED cairo>=1.14)
|
||||
set(luacairo_libs ${CAIRO_LIBRARIES} ${LUA_LIBRARIES})
|
||||
set(luacairo_includes ${CAIRO_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
|
||||
|
||||
if(BUILD_LUA_CAIRO_XLIB)
|
||||
pkg_check_modules(CAIROXLIB REQUIRED cairo-xlib)
|
||||
set(luacairo_libs ${CAIROXLIB_LIBRARIES} ${luacairo_libs})
|
||||
set(luacairo_includes ${CAIROXLIB_INCLUDE_DIRS} ${luacairo_includes})
|
||||
endif(BUILD_LUA_CAIRO_XLIB)
|
||||
|
||||
find_program(APP_PATCH patch)
|
||||
|
||||
if(NOT APP_PATCH)
|
||||
message(FATAL_ERROR "Unable to find program 'patch'")
|
||||
endif(NOT APP_PATCH)
|
||||
endif(BUILD_LUA_CAIRO)
|
||||
|
||||
if(BUILD_LUA_IMLIB2)
|
||||
pkg_search_module(IMLIB2 REQUIRED imlib2 Imlib2)
|
||||
set(luaimlib2_libs ${IMLIB2_LIBS} ${IMLIB2_LDFLAGS} ${LUA_LIBRARIES})
|
||||
set(luaimlib2_includes
|
||||
${IMLIB2_INCLUDE_DIRS}
|
||||
${LUA_INCLUDE_DIR}
|
||||
${X11_INCLUDE_DIR})
|
||||
endif(BUILD_LUA_IMLIB2)
|
||||
|
||||
if(BUILD_LUA_RSVG)
|
||||
pkg_check_modules(RSVG REQUIRED librsvg-2.0>=2.52)
|
||||
set(luarsvg_libs ${RSVG_LIBRARIES} ${LUA_LIBRARIES})
|
||||
set(luarsvg_includes ${RSVG_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
|
||||
endif(BUILD_LUA_RSVG)
|
||||
|
||||
if(BUILD_AUDACIOUS)
|
||||
set(WANT_GLIB true)
|
||||
pkg_check_modules(NEW_AUDACIOUS audacious>=1.4.0)
|
||||
|
||||
if(NEW_AUDACIOUS_FOUND)
|
||||
pkg_check_modules(AUDACIOUS REQUIRED audclient>=1.4.0)
|
||||
pkg_check_modules(DBUS_GLIB REQUIRED dbus-glib-1)
|
||||
else(NEW_AUDACIOUS_FOUND)
|
||||
pkg_check_modules(AUDACIOUS REQUIRED audacious<1.4.0)
|
||||
endif(NEW_AUDACIOUS_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${AUDACIOUS_LIBRARIES} ${DBUS_GLIB_LIBRARIES})
|
||||
set(conky_includes
|
||||
${conky_includes}
|
||||
${AUDACIOUS_INCLUDE_DIRS}
|
||||
${DBUS_GLIB_INCLUDE_DIRS})
|
||||
endif(BUILD_AUDACIOUS)
|
||||
|
||||
if(BUILD_XMMS2)
|
||||
pkg_check_modules(XMMS2 REQUIRED xmms2-client>=0.6)
|
||||
set(conky_libs ${conky_libs} ${XMMS2_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${XMMS2_INCLUDE_DIRS})
|
||||
endif(BUILD_XMMS2)
|
||||
|
||||
if(BUILD_CURL)
|
||||
set(WANT_CURL true)
|
||||
endif(BUILD_CURL)
|
||||
|
||||
if(BUILD_RSS)
|
||||
set(WANT_CURL true)
|
||||
set(WANT_LIBXML2 true)
|
||||
endif(BUILD_RSS)
|
||||
|
||||
if(BUILD_NVIDIA)
|
||||
find_path(XNVCtrl_INCLUDE_PATH NVCtrl/NVCtrl.h ${INCLUDE_SEARCH_PATH})
|
||||
find_library(XNVCtrl_LIB NAMES XNVCtrl)
|
||||
|
||||
if(XNVCtrl_INCLUDE_PATH AND XNVCtrl_LIB)
|
||||
set(XNVCtrl_FOUND true)
|
||||
set(conky_libs ${conky_libs} ${XNVCtrl_LIB})
|
||||
set(conky_includes ${conky_includes} ${XNVCtrl_INCLUDE_PATH})
|
||||
else(XNVCtrl_INCLUDE_PATH AND XNVCtrl_LIB)
|
||||
message(FATAL_ERROR "Unable to find XNVCtrl library")
|
||||
endif(XNVCtrl_INCLUDE_PATH AND XNVCtrl_LIB)
|
||||
endif(BUILD_NVIDIA)
|
||||
|
||||
if(BUILD_IMLIB2)
|
||||
pkg_search_module(IMLIB2 REQUIRED imlib2 Imlib2)
|
||||
set(conky_libs ${conky_libs} ${IMLIB2_LIBS} ${IMLIB2_LDFLAGS})
|
||||
set(conky_includes ${conky_includes} ${IMLIB2_INCLUDE_DIRS})
|
||||
endif(BUILD_IMLIB2)
|
||||
|
||||
if(BUILD_JOURNAL)
|
||||
pkg_search_module(SYSTEMD REQUIRED libsystemd>=205 libsystemd-journal>=205)
|
||||
set(conky_libs ${conky_libs} ${SYSTEMD_LIB} ${SYSTEMD_LDFLAGS})
|
||||
set(conky_includes ${conky_includes} ${SYSTEMD_INCLUDE_DIRS})
|
||||
endif(BUILD_JOURNAL)
|
||||
|
||||
if(BUILD_PULSEAUDIO)
|
||||
pkg_check_modules(PULSEAUDIO REQUIRED libpulse)
|
||||
set(conky_libs ${conky_libs} ${PULSEAUDIO_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${PULSEAUDIO_INCLUDE_DIRS})
|
||||
endif(BUILD_PULSEAUDIO)
|
||||
|
||||
if(WANT_CURL)
|
||||
pkg_check_modules(CURL REQUIRED libcurl)
|
||||
set(conky_libs ${conky_libs} ${CURL_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${CURL_INCLUDE_DIRS})
|
||||
endif(WANT_CURL)
|
||||
|
||||
# Common libraries
|
||||
if(WANT_GLIB)
|
||||
pkg_check_modules(GLIB REQUIRED glib-2.0>=2.36)
|
||||
set(conky_libs ${conky_libs} ${GLIB_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${GLIB_INCLUDE_DIRS})
|
||||
endif(WANT_GLIB)
|
||||
|
||||
if(WANT_CURL)
|
||||
pkg_check_modules(CURL REQUIRED libcurl)
|
||||
set(conky_libs ${conky_libs} ${CURL_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${CURL_INCLUDE_DIRS})
|
||||
endif(WANT_CURL)
|
||||
|
||||
if(WANT_LIBXML2)
|
||||
include(FindLibXml2)
|
||||
|
||||
if(NOT LIBXML2_FOUND)
|
||||
message(FATAL_ERROR "Unable to find libxml2 library")
|
||||
endif(NOT LIBXML2_FOUND)
|
||||
|
||||
set(conky_libs ${conky_libs} ${LIBXML2_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${LIBXML2_INCLUDE_DIR})
|
||||
endif(WANT_LIBXML2)
|
||||
|
||||
# Look for doc generation programs
|
||||
if(BUILD_DOCS)
|
||||
# Used for doc generation
|
||||
find_program(APP_PANDOC pandoc)
|
||||
|
||||
if(NOT APP_PANDOC)
|
||||
message(FATAL_ERROR "Unable to find program 'pandoc'")
|
||||
endif(NOT APP_PANDOC)
|
||||
|
||||
mark_as_advanced(APP_PANDOC)
|
||||
endif(BUILD_DOCS)
|
||||
|
||||
if(BUILD_DOCS OR BUILD_EXTRAS)
|
||||
# Python3 with Jinja2 and PyYaml required for manpage generation.
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
execute_process(
|
||||
COMMAND ${Python3_EXECUTABLE} -c "import yaml"
|
||||
RESULT_VARIABLE EXIT_CODE
|
||||
OUTPUT_QUIET
|
||||
)
|
||||
|
||||
if(NOT ${EXIT_CODE} EQUAL 0)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"The \"PyYAML\" Python3 package is not installed. Please install it using the following command: \"pip3 install pyyaml\"."
|
||||
)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${Python3_EXECUTABLE} -c "import jinja2"
|
||||
RESULT_VARIABLE EXIT_CODE
|
||||
OUTPUT_QUIET
|
||||
)
|
||||
|
||||
if(NOT ${EXIT_CODE} EQUAL 0)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"The \"Jinja2\" Python3 package is not installed. Please install it using the following command: \"pip3 install Jinja2\"."
|
||||
)
|
||||
endif()
|
||||
endif(BUILD_DOCS OR BUILD_EXTRAS)
|
||||
|
||||
if(BUILD_COLOUR_NAME_MAP)
|
||||
find_program(APP_GPERF gperf)
|
||||
|
||||
if(NOT APP_GPERF)
|
||||
message(FATAL_ERROR "Unable to find program 'gperf' (required at build-time as of Conky v1.20.2)")
|
||||
endif(NOT APP_GPERF)
|
||||
|
||||
mark_as_advanced(APP_GPERF)
|
||||
endif(BUILD_COLOUR_NAME_MAP)
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
set(DEBUG true)
|
||||
endif(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
|
||||
# The version numbers are simply derived from the date and number of commits
|
||||
# since start of month
|
||||
if(DEBUG)
|
||||
execute_process(COMMAND ${APP_GIT} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git
|
||||
log --since=${VERSION_MAJOR}-${VERSION_MINOR}-01
|
||||
--pretty=oneline
|
||||
COMMAND ${APP_WC} -l
|
||||
COMMAND ${APP_AWK} "{print $1}"
|
||||
RESULT_VARIABLE RETVAL
|
||||
OUTPUT_VARIABLE COMMIT_COUNT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif(DEBUG)
|
||||
67
cmake/DependentOption.cmake
Normal file
67
cmake/DependentOption.cmake
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
DependentOption
|
||||
--------------------
|
||||
Roughly based on CMakeDependentOption:
|
||||
https://github.com/Kitware/CMake/blob/master/Modules/CMakeDependentOption.cmake
|
||||
|
||||
Modified to so it produces warnings instead of hiding an option completely and
|
||||
sets a default value.
|
||||
Difference is that `depends` argument is ALWAYS a semicolon separated list of
|
||||
<expr> tokens.
|
||||
|
||||
Argument meaning and order are the same, and there's an additional (warn)
|
||||
argument which is the message printed if the end-user enabled a feature which
|
||||
isn't "possible".
|
||||
|
||||
Actual checks are deferred until RUN_DEPENDENCY_CHECKS() is called in order to
|
||||
allow out of order declaration of dependencies and dependecy graph cycles.
|
||||
As the checks can affect each other they're run in a loop until the graph settles.
|
||||
#]=======================================================================]
|
||||
|
||||
set(__DEPENDENT_OPTIONS_CHANGE_HAPPENED true)
|
||||
set(__DEPENDENT_OPTIONS_LATER_INVOKED_CODE "")
|
||||
|
||||
macro(DEPENDENT_OPTION option doc default depends else warn)
|
||||
option(${option} "${doc}" "${default}")
|
||||
|
||||
string(APPEND __DEPENDENT_OPTIONS_LATER_INVOKED_CODE "
|
||||
set(${option}_POSSIBLE 1)
|
||||
string(REGEX MATCHALL \"[^;]+\" __${option}_TOKENS \"${depends}\")
|
||||
foreach(it \${__${option}_TOKENS})
|
||||
cmake_language(EVAL CODE \"
|
||||
if (\${it})
|
||||
else()
|
||||
set(${option}_POSSIBLE 0)
|
||||
endif()\")
|
||||
endforeach()
|
||||
unset(__${option}_TOKENS)
|
||||
if(NOT ${option}_POSSIBLE)
|
||||
if(NOT \"\${${option}}\" STREQUAL \"${else}\")
|
||||
message(NOTICE \"${warn}; setting to '${else}'.\")
|
||||
set(${option} ${else} CACHE BOOL \"${doc}\" FORCE)
|
||||
set(__DEPENDENT_OPTIONS_CHANGE_HAPPENED true)
|
||||
endif()
|
||||
endif()
|
||||
unset(${option}_POSSIBLE)")
|
||||
endmacro()
|
||||
|
||||
macro(RUN_DEPENDENCY_CHECKS)
|
||||
# controls max allowed dependency chain to avoid infinite loops during
|
||||
# configure phase
|
||||
set(__DEPENDENT_OPTIONS_LOOP_COUNTER 10)
|
||||
|
||||
while(__DEPENDENT_OPTIONS_CHANGE_HAPPENED)
|
||||
MATH(EXPR __DEPENDENT_OPTIONS_LOOP_COUNTER "${__DEPENDENT_OPTIONS_LOOP_COUNTER}-1")
|
||||
set(__DEPENDENT_OPTIONS_CHANGE_HAPPENED false)
|
||||
cmake_language(EVAL CODE "${__DEPENDENT_OPTIONS_LATER_INVOKED_CODE}")
|
||||
if(__DEPENDENT_OPTIONS_LOOP_COUNTER LESS_EQUAL "0")
|
||||
break()
|
||||
endif()
|
||||
endwhile()
|
||||
unset(__DEPENDENT_OPTIONS_LOOP_COUNTER)
|
||||
set(__DEPENDENT_OPTIONS_CHANGE_HAPPENED true)
|
||||
set(__DEPENDENT_OPTIONS_LATER_INVOKED_CODE "")
|
||||
endmacro()
|
||||
27
cmake/FindClangFormat.cmake
Normal file
27
cmake/FindClangFormat.cmake
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Find Clang format
|
||||
#
|
||||
|
||||
set(ClangFormat_BIN_NAME
|
||||
clang-format
|
||||
clang-format-5.0
|
||||
clang-format-6.0
|
||||
clang-format-7
|
||||
clang-format-8
|
||||
clang-format-9
|
||||
clang-format-10
|
||||
clang-format-11)
|
||||
|
||||
find_program(ClangFormat_BIN NAMES ${ClangFormat_BIN_NAME})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ClangFormat DEFAULT_MSG ClangFormat_BIN)
|
||||
|
||||
mark_as_advanced(ClangFormat_BIN)
|
||||
|
||||
if(ClangFormat_FOUND)
|
||||
# A CMake script to find all source files and setup clang-format targets for
|
||||
# them
|
||||
include(clang-format)
|
||||
else()
|
||||
message("clang-format not found. Not setting up format targets")
|
||||
endif()
|
||||
27
cmake/FindClangTidy.cmake
Normal file
27
cmake/FindClangTidy.cmake
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Find Clang tidy
|
||||
#
|
||||
|
||||
set(ClangTidy_BIN_NAME
|
||||
clang-tidy
|
||||
clang-tidy-5.0
|
||||
clang-tidy-6.0
|
||||
clang-tidy-7
|
||||
clang-tidy-8
|
||||
clang-tidy-9
|
||||
clang-tidy-10
|
||||
clang-tidy-11)
|
||||
|
||||
find_program(ClangTidy_BIN NAMES ${ClangTidy_BIN_NAME})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ClangTidy DEFAULT_MSG ClangTidy_BIN)
|
||||
|
||||
mark_as_advanced(ClangTidy_BIN)
|
||||
|
||||
if(ClangTidy_FOUND)
|
||||
# A CMake script to find all source files and setup clang-tidy targets for
|
||||
# them
|
||||
include(clang-tidy)
|
||||
else()
|
||||
message("clang-tidy not found. Not setting up tidy targets")
|
||||
endif()
|
||||
54
cmake/FindWayland.cmake
Normal file
54
cmake/FindWayland.cmake
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
find_path(
|
||||
Wayland_CLIENT_INCLUDE_DIR
|
||||
NAMES wayland-client.h
|
||||
)
|
||||
|
||||
find_library(
|
||||
Wayland_CLIENT_LIBRARY
|
||||
NAMES wayland-client libwayland-client
|
||||
)
|
||||
|
||||
if(Wayland_CLIENT_INCLUDE_DIR AND Wayland_CLIENT_LIBRARY)
|
||||
add_library(wayland::client UNKNOWN IMPORTED)
|
||||
|
||||
set_target_properties(
|
||||
wayland::client PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Wayland_CLIENT_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${Wayland_CLIENT_LIBRARY}"
|
||||
)
|
||||
endif()
|
||||
|
||||
find_path(
|
||||
Wayland_SERVER_INCLUDE_DIR
|
||||
NAMES wayland-server.h
|
||||
)
|
||||
|
||||
find_library(
|
||||
Wayland_SERVER_LIBRARY
|
||||
NAMES wayland-server libwayland-server
|
||||
)
|
||||
|
||||
if(Wayland_SERVER_INCLUDE_DIR AND Wayland_SERVER_LIBRARY)
|
||||
add_library(wayland::server UNKNOWN IMPORTED)
|
||||
|
||||
set_target_properties(
|
||||
wayland::server PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Wayland_SERVER_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${Wayland_SERVER_LIBRARY}"
|
||||
)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
Wayland
|
||||
REQUIRED_VARS Wayland_CLIENT_LIBRARY Wayland_CLIENT_INCLUDE_DIR Wayland_SERVER_LIBRARY Wayland_SERVER_INCLUDE_DIR
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
Wayland_CLIENT_INCLUDE_DIR
|
||||
Wayland_CLIENT_LIBRARY
|
||||
Wayland_SERVER_INCLUDE_DIR
|
||||
Wayland_SERVER_LIBRARY
|
||||
)
|
||||
61
cmake/ToLua.cmake
Normal file
61
cmake/ToLua.cmake
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#
|
||||
# Conky, a system monitor, based on torsmo
|
||||
#
|
||||
# Please see COPYING for details
|
||||
#
|
||||
# Copyright (c) 2005-2024 Brenden Matthews, et. al. (see AUTHORS) All rights
|
||||
# reserved.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details. You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
function(wrap_tolua VAR FIL)
|
||||
set(INCL)
|
||||
set(${VAR})
|
||||
|
||||
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
||||
get_filename_component(FIL_WE ${FIL} NAME_WE)
|
||||
list(APPEND ${VAR} "${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.cc")
|
||||
|
||||
if(DEFINED ARGV2)
|
||||
get_filename_component(PATCH ${ARGV2} ABSOLUTE)
|
||||
set(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}-orig.cc)
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.cc
|
||||
COMMAND ${APP_PATCH} -s ${TOLUA_OUT} ${PATCH} -o
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.cc
|
||||
DEPENDS ${TOLUA_OUT} ${PATCH}
|
||||
COMMENT "Patching lib${FIL_WE}-orig.cc"
|
||||
VERBATIM)
|
||||
set_source_files_properties(${TOLUA_OUT} PROPERTIES GENERATED TRUE)
|
||||
else()
|
||||
set(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.cc)
|
||||
endif(DEFINED ARGV2)
|
||||
|
||||
# Call toluapp from 3rdparty/ path directly. The last argument to toluapp is
|
||||
# the path to the tolua Lua sources.
|
||||
add_custom_command(OUTPUT ${TOLUA_OUT} ${INCL}
|
||||
COMMAND toluapp -n ${FIL_WE} -o ${TOLUA_OUT} ${ABS_FIL}
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/toluapp/src/bin/lua/
|
||||
DEPENDS ${ABS_FIL}
|
||||
COMMENT "Running tolua++ on ${FIL}"
|
||||
VERBATIM)
|
||||
|
||||
set_source_files_properties(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(
|
||||
${${VAR}}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
"-Wno-unused-parameter -Wno-cast-qual -Wno-error=pedantic"
|
||||
)
|
||||
|
||||
set(${VAR} ${${VAR}} PARENT_SCOPE)
|
||||
endfunction(wrap_tolua)
|
||||
46
cmake/UninstallConky.cmake.in
Normal file
46
cmake/UninstallConky.cmake.in
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
#Conky, a system monitor, based on torsmo
|
||||
#
|
||||
#Please see COPYING for details
|
||||
#
|
||||
#Copyright(c) 2005 - 2024 Brenden Matthews, et.al.(see AUTHORS)All rights
|
||||
#reserved.
|
||||
#
|
||||
#This program is free software : you can redistribute it and / or \
|
||||
modify it under
|
||||
#the terms of the GNU General Public License as published by the Free Software
|
||||
#Foundation, either version 3 of the License, or (at your option) any later
|
||||
#version.
|
||||
#
|
||||
#This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
#FOR A PARTICULAR PURPOSE.See the GNU General Public License for more
|
||||
#details.You should have received a copy of the GNU General Public License
|
||||
#along with this program.If not, see < http: // www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
if (NOT EXISTS ${CMAKE_BINARY_DIR} / install_manifest.txt)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Cannot find install manifest: ${CMAKE_BINARY_DIR}/install_manifest.txt")
|
||||
endif()
|
||||
|
||||
file(READ "${CMAKE_BINARY_DIR}/install_manifest.txt" files) string(
|
||||
REGEX REPLACE
|
||||
"\n"
|
||||
";" files "${files}") foreach (file ${files})
|
||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if (
|
||||
IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS
|
||||
"$ENV{DESTDIR}${file}")
|
||||
exec_program(
|
||||
${CMAKE_COMMAND} ARGS
|
||||
"-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval) if (NOT
|
||||
"${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif() else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS
|
||||
"$ENV{DESTDIR}${file}")
|
||||
message(STATUS
|
||||
"File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif() endforeach()
|
||||
8
cmake/build.h.in
Normal file
8
cmake/build.h.in
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef __BUILD_H
|
||||
#define __BUILD_H
|
||||
|
||||
/* Conky build info */
|
||||
|
||||
#define BUILD_ARCH "@BUILD_ARCH@"
|
||||
|
||||
#endif /* __BUILD_H */
|
||||
30
cmake/clang-format.cmake
Normal file
30
cmake/clang-format.cmake
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
set(ClangFormat_CXX_FILE_EXTENSIONS
|
||||
${ClangFormat_CXX_FILE_EXTENSIONS}
|
||||
*.cpp
|
||||
*.h
|
||||
*.cxx
|
||||
*.hxx
|
||||
*.hpp
|
||||
*.cc
|
||||
*.hh
|
||||
*.ipp)
|
||||
|
||||
foreach(PATTERN ${ClangFormat_CXX_FILE_EXTENSIONS})
|
||||
list(APPEND ClangFormat_CXX_PATTERN ${CMAKE_SOURCE_DIR}/src/${PATTERN})
|
||||
list(APPEND ClangFormat_CXX_PATTERN ${CMAKE_SOURCE_DIR}/tests/${PATTERN})
|
||||
list(APPEND ClangFormat_CXX_PATTERN ${CMAKE_SOURCE_DIR}/lua/${PATTERN})
|
||||
endforeach()
|
||||
|
||||
file(GLOB_RECURSE ClangFormat_SRCS ${ClangFormat_CXX_PATTERN})
|
||||
|
||||
# Remove catch2 from format sources
|
||||
list(REMOVE_ITEM ClangFormat_SRCS ${CMAKE_SOURCE_DIR}/tests/catch2/catch.hpp)
|
||||
|
||||
add_custom_target(clang-format
|
||||
COMMAND ${ClangFormat_BIN} -style=file -i
|
||||
${ClangFormat_SRCS})
|
||||
add_custom_target(check-clang-format
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/bin/run-clang-format.py
|
||||
--color always
|
||||
--clang-format-executable ${ClangFormat_BIN}
|
||||
${ClangFormat_SRCS})
|
||||
27
cmake/clang-tidy.cmake
Normal file
27
cmake/clang-tidy.cmake
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
get_target_property(ClangTidy_SRCS_TMP conky SOURCES)
|
||||
get_target_property(conky_SRC_DIR conky SOURCE_DIR)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
get_target_property(ClangTidy_SRCS_TMP_CORE conky_core SOURCES)
|
||||
list(APPEND ClangTidy_SRCS_TMP ${ClangTidy_SRCS_TMP_CORE})
|
||||
endif()
|
||||
|
||||
foreach(TMP_SRC ${ClangTidy_SRCS_TMP})
|
||||
if("${TMP_SRC}" MATCHES ".*\.cc|.*\.hh|.*\.[chi]pp|.*\.[chi]xx|.*\.ii")
|
||||
list(APPEND ClangTidy_SRCS ${conky_SRC_DIR}/${TMP_SRC})
|
||||
endif()
|
||||
endforeach(TMP_SRC)
|
||||
|
||||
get_target_property(CLANG_INCLUDES_tmp conky INCLUDE_DIRECTORIES)
|
||||
foreach(TMP_INCLUDE ${CLANG_INCLUDES_tmp})
|
||||
list(APPEND CLANG_INCLUDES -I${TMP_INCLUDE})
|
||||
endforeach(TMP_INCLUDE)
|
||||
|
||||
add_custom_target(clang-tidy
|
||||
COMMAND ${ClangTidy_BIN} -config='' -fix -format-style=file
|
||||
${ClangTidy_SRCS}
|
||||
-- -std=c++17 -I${CMAKE_BINARY_DIR} ${CLANG_INCLUDES})
|
||||
add_custom_target(check-clang-tidy
|
||||
COMMAND ${ClangTidy_BIN} -config='' -format-style=file
|
||||
${ClangTidy_SRCS}
|
||||
-- -std=c++17 -I${CMAKE_BINARY_DIR} ${CLANG_INCLUDES})
|
||||
152
cmake/config.h.in
Normal file
152
cmake/config.h.in
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* Auto-generated header for CMake. See config.h.in if you need to modify the
|
||||
* original.
|
||||
*/
|
||||
|
||||
#ifndef _conky_config_h_
|
||||
#define _conky_config_h_
|
||||
|
||||
#cmakedefine DEBUG
|
||||
|
||||
#define SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
|
||||
#define PACKAGE_NAME "@PROJECT_NAME@"
|
||||
#define VERSION "@VERSION@"
|
||||
#define SYSTEM_CONFIG_FILE "@SYSTEM_CONFIG_FILE@"
|
||||
#define PACKAGE_LIBDIR "@PACKAGE_LIBRARY_DIR@"
|
||||
#define DEFAULTNETDEV "@DEFAULTNETDEV@"
|
||||
#define XDG_CONFIG_FILE "@XDG_CONFIG_FILE@"
|
||||
#define CONFIG_FILE "@CONFIG_FILE@"
|
||||
#define LOCALE_DIR "@LOCALE_DIR@"
|
||||
#define MAX_USER_TEXT_DEFAULT @MAX_USER_TEXT_DEFAULT@
|
||||
#define DEFAULT_TEXT_BUFFER_SIZE @DEFAULT_TEXT_BUFFER_SIZE@
|
||||
#define MAX_NET_INTERFACES @MAX_NET_INTERFACES@
|
||||
#define HTTPPORT @HTTPPORT@
|
||||
|
||||
#cmakedefine BUILD_I18N 1
|
||||
|
||||
#cmakedefine HAVE_SYS_STATFS_H 1
|
||||
#cmakedefine HAVE_SYS_PARAM_H 1
|
||||
#cmakedefine HAVE_SYS_INOTIFY_H 1
|
||||
#cmakedefine HAVE_DIRENT_H 1
|
||||
|
||||
#cmakedefine HAVE_SOME_SOUNDCARD_H 1
|
||||
#cmakedefine HAVE_LINUX_SOUNDCARD_H 1
|
||||
|
||||
#cmakedefine HAVE_STRNDUP 1
|
||||
|
||||
#cmakedefine HAVE_FOPENCOOKIE 1
|
||||
#cmakedefine HAVE_FUNOPEN 1
|
||||
|
||||
#cmakedefine HAVE_PIPE2 1
|
||||
#cmakedefine HAVE_O_CLOEXEC 1
|
||||
|
||||
#cmakedefine HAVE_CLOCK_GETTIME 1
|
||||
|
||||
#cmakedefine HAVE_XCB 1
|
||||
#cmakedefine HAVE_XCB_ERRORS 1
|
||||
|
||||
#cmakedefine BUILD_WAYLAND 1
|
||||
|
||||
#cmakedefine BUILD_X11 1
|
||||
|
||||
#cmakedefine OWN_WINDOW 1
|
||||
|
||||
#cmakedefine BUILD_MOUSE_EVENTS 1
|
||||
|
||||
#cmakedefine BUILD_XDAMAGE 1
|
||||
|
||||
#cmakedefine BUILD_XINERAMA 1
|
||||
|
||||
#cmakedefine BUILD_XFT 1
|
||||
|
||||
#cmakedefine BUILD_XSHAPE 1
|
||||
|
||||
#cmakedefine BUILD_XFIXES 1
|
||||
|
||||
#cmakedefine BUILD_XINPUT 1
|
||||
|
||||
#cmakedefine BUILD_ARGB 1
|
||||
|
||||
#cmakedefine BUILD_XDBE 1
|
||||
|
||||
#cmakedefine BUILD_PORT_MONITORS 1
|
||||
|
||||
#cmakedefine BUILD_AUDACIOUS 1
|
||||
|
||||
#cmakedefine NEW_AUDACIOUS_FOUND 1
|
||||
|
||||
#cmakedefine BUILD_MPD 1
|
||||
|
||||
#cmakedefine BUILD_MYSQL 1
|
||||
|
||||
#cmakedefine BUILD_MOC 1
|
||||
|
||||
#cmakedefine BUILD_NVIDIA 0
|
||||
|
||||
#cmakedefine BUILD_XMMS2 1
|
||||
|
||||
#cmakedefine BUILD_HDDTEMP 1
|
||||
|
||||
#cmakedefine BUILD_LIBXML2 1
|
||||
|
||||
#cmakedefine BUILD_CURL 1
|
||||
|
||||
#cmakedefine BUILD_IMLIB2 1
|
||||
|
||||
#cmakedefine BUILD_MATH 1
|
||||
|
||||
#cmakedefine BUILD_BUILTIN_CONFIG 1
|
||||
|
||||
#cmakedefine BUILD_OLD_CONFIG 1
|
||||
|
||||
#cmakedefine BUILD_NCURSES 1
|
||||
#cmakedefine LEAKFREE_NCURSES 1
|
||||
|
||||
#cmakedefine BUILD_APCUPSD 1
|
||||
|
||||
#cmakedefine BUILD_IOSTATS 1
|
||||
|
||||
#cmakedefine BUILD_IPGFREQ 0
|
||||
|
||||
#cmakedefine BUILD_WLAN 1
|
||||
|
||||
#cmakedefine BUILD_ICAL 1
|
||||
|
||||
#cmakedefine BUILD_IRC 1
|
||||
|
||||
#cmakedefine BUILD_PULSEAUDIO 1
|
||||
|
||||
#cmakedefine BUILD_INTEL_BACKLIGHT 0
|
||||
|
||||
#cmakedefine BUILD_IPV6 1
|
||||
|
||||
#cmakedefine BUILD_HTTP 1
|
||||
|
||||
#cmakedefine BUILD_GUI 1
|
||||
|
||||
#cmakedefine BUILD_ICONV 1
|
||||
|
||||
#cmakedefine BUILD_LUA_CAIRO 1
|
||||
|
||||
#cmakedefine BUILD_LUA_IMLIB2 1
|
||||
|
||||
#cmakedefine BUILD_LUA_RSVG 1
|
||||
|
||||
#cmakedefine BUILD_IBM 1
|
||||
|
||||
#cmakedefine BUILD_RSS 1
|
||||
|
||||
#cmakedefine BUILD_CMUS 1
|
||||
|
||||
#cmakedefine BUILD_JOURNAL 1
|
||||
|
||||
#cmakedefine BUILD_HSV_GRADIENT 1
|
||||
|
||||
#cmakedefine BUILD_COLOUR_NAME_MAP 1
|
||||
|
||||
#cmakedefine HAVE_STATFS64 1
|
||||
#ifndef HAVE_STATFS64
|
||||
#define statfs64 statfs
|
||||
#endif
|
||||
|
||||
#endif /* _conky_config_h_ */
|
||||
18
cmake/scripts/clang-format-check-changed
Executable file
18
cmake/scripts/clang-format-check-changed
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Required because cmake root isn't git root in this example
|
||||
CLANG_FORMAT_BIN=$1
|
||||
GIT_ROOT=`git rev-parse --show-toplevel`
|
||||
|
||||
pushd ${GIT_ROOT} > /dev/null
|
||||
|
||||
git status --porcelain \
|
||||
| egrep '*\.cpp|*\.h|*\.cxx|*\.hxx|*\.hpp|*\.cc' \
|
||||
| awk -F " " '{print $NF}' \
|
||||
| xargs -r ${CLANG_FORMAT_BIN} -style=file -output-replacements-xml \
|
||||
| grep "replacement offset" 2>&1 > /dev/null
|
||||
|
||||
RET=$?
|
||||
popd > /dev/null
|
||||
|
||||
exit ${RET}
|
||||
163
cmake/scripts/clang-format-check-changed.py
Executable file
163
cmake/scripts/clang-format-check-changed.py
Executable file
|
|
@ -0,0 +1,163 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
def check_file(filename, excludes, extensions):
|
||||
"""
|
||||
Check if a file should be included in our check
|
||||
"""
|
||||
name, ext = os.path.splitext(filename)
|
||||
|
||||
if len(ext) > 0 and ext in extensions:
|
||||
if len(excludes) == 0:
|
||||
return True
|
||||
|
||||
for exclude in excludes:
|
||||
if exclude in filename:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def check_directory(directory, excludes, extensions):
|
||||
output = []
|
||||
|
||||
if len(excludes) > 0:
|
||||
for exclude in excludes:
|
||||
if exclude in directory:
|
||||
directory_excluded = False
|
||||
return output
|
||||
|
||||
for root, _, files in os.walk(directory):
|
||||
for file in files:
|
||||
filename = os.path.join(root, file)
|
||||
if check_file(filename, excludes, extensions):
|
||||
print("Will check file [{}]".format(filename))
|
||||
output.append(filename)
|
||||
return output
|
||||
|
||||
def get_git_root(git_bin):
|
||||
cmd = [git_bin, "rev-parse", "--show-toplevel"]
|
||||
try:
|
||||
return subprocess.check_output(cmd).strip()
|
||||
except subprocess.CalledProcessError, e:
|
||||
print("Error calling git [{}]".format(e))
|
||||
raise
|
||||
|
||||
def clean_git_filename(line):
|
||||
"""
|
||||
Takes a line from git status --porcelain and returns the filename
|
||||
"""
|
||||
file = None
|
||||
git_status = line[:2]
|
||||
# Not an exhaustive list of git status output but should
|
||||
# be enough for this case
|
||||
# check if this is a delete
|
||||
if 'D' in git_status:
|
||||
return None
|
||||
# ignored file
|
||||
if '!' in git_status:
|
||||
return None
|
||||
# Covers renamed files
|
||||
if '->' in line:
|
||||
file = line[3:].split('->')[-1].strip()
|
||||
else:
|
||||
file = line[3:].strip()
|
||||
|
||||
return file
|
||||
|
||||
|
||||
def get_changed_files(git_bin, excludes, file_extensions):
|
||||
"""
|
||||
Run git status and return the list of changed files
|
||||
"""
|
||||
extensions = file_extensions.split(",")
|
||||
# arguments coming from cmake will be *.xx. We want to remove the *
|
||||
for i, extension in enumerate(extensions):
|
||||
if extension[0] == '*':
|
||||
extensions[i] = extension[1:]
|
||||
|
||||
git_root = get_git_root(git_bin)
|
||||
|
||||
cmd = [git_bin, "status", "--porcelain", "--ignore-submodules"]
|
||||
print("git cmd = {}".format(cmd))
|
||||
output = []
|
||||
returncode = 0
|
||||
try:
|
||||
cmd_output = subprocess.check_output(cmd)
|
||||
for line in cmd_output.split('\n'):
|
||||
if len(line) > 0:
|
||||
file = clean_git_filename(line)
|
||||
if not file:
|
||||
continue
|
||||
file = os.path.join(git_root, file)
|
||||
|
||||
if file[-1] == "/":
|
||||
directory_files = check_directory(
|
||||
file, excludes, file_extensions)
|
||||
output = output + directory_files
|
||||
else:
|
||||
if check_file(file, excludes, file_extensions):
|
||||
print("Will check file [{}]".format(file))
|
||||
output.append(file)
|
||||
|
||||
except subprocess.CalledProcessError, e:
|
||||
print("Error calling git [{}]".format(e))
|
||||
returncode = e.returncode
|
||||
|
||||
return output, returncode
|
||||
|
||||
|
||||
def run_clang_format(clang_format_bin, changed_files):
|
||||
"""
|
||||
Run clang format on a list of files
|
||||
@return 0 if formatted correctly.
|
||||
"""
|
||||
if len(changed_files) == 0:
|
||||
return 0
|
||||
cmd = [clang_format_bin, "-style=file",
|
||||
"-output-replacements-xml"] + changed_files
|
||||
print("clang-format cmd = {}".format(cmd))
|
||||
try:
|
||||
cmd_output = subprocess.check_output(cmd)
|
||||
if "replacement offset" in cmd_output:
|
||||
print("ERROR: Changed files don't match format")
|
||||
return 1
|
||||
except subprocess.CalledProcessError, e:
|
||||
print("Error calling clang-format [{}]".format(e))
|
||||
return e.returncode
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def cli():
|
||||
# global params
|
||||
parser = argparse.ArgumentParser(prog='clang-format-check-changed',
|
||||
description='Checks if files changed in git match the .clang-format specification')
|
||||
parser.add_argument("--file-extensions", type=str,
|
||||
default=".cpp,.h,.cxx,.hxx,.hpp,.cc,.ipp",
|
||||
help="Comma separated list of file extensions to check")
|
||||
parser.add_argument('--exclude', action='append', default=[],
|
||||
help='Will not match the files / directories with these in the name')
|
||||
parser.add_argument('--clang-format-bin', type=str, default="clang-format",
|
||||
help="The clang format binary")
|
||||
parser.add_argument('--git-bin', type=str, default="git",
|
||||
help="The git binary")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Run gcovr to get the .gcda files form .gcno
|
||||
changed_files, returncode = get_changed_files(
|
||||
args.git_bin, args.exclude, args.file_extensions)
|
||||
if returncode != 0:
|
||||
return returncode
|
||||
|
||||
return run_clang_format(args.clang_format_bin, changed_files)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(cli())
|
||||
Loading…
Add table
Add a link
Reference in a new issue