From 48b4bd18834da9459b14168413a494de662771ce Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Mon, 31 Aug 2015 17:26:01 +0200 Subject: [PATCH] Merging upstream version 0.3.0+201500806 --- CMakeLists.txt | 169 +++++++++++++------ cmake/LXQtCompilerSettings.cmake | 141 ++++++++++++++++ cmake/create_pkgconfig_file.cmake | 265 +++++++++++++++++++++++++++--- cmake/sysstat-config.cmake.in | 31 ++-- cmake/sysstat_use.cmake | 1 - memstat.cpp | 12 +- 6 files changed, 511 insertions(+), 108 deletions(-) create mode 100644 cmake/LXQtCompilerSettings.cmake delete mode 100644 cmake/sysstat_use.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e8bb8a7..9e59a40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,29 +1,26 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) project(libsysstat) -# Set default installation paths -set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries") -set(INCLUDE_INSTALL_DIR include CACHE PATH "Installation path for includes") - set(MAJOR_VERSION 0) -set(MINOR_VERSION 2) +set(MINOR_VERSION 3) set(PATCH_VERSION 0) set(SYSSTAT_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") -add_definitions(-DMAJOR_VERSION=${MAJOR_VERSION}) -add_definitions(-DMINOR_VERSION=${MINOR_VERSION}) -add_definitions(-DPATCH_VERSION=${PATCH_VERSION}) -add_definitions(-DSYSSTAT_LIBRARY) +# additional cmake files +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -# use gcc visibility feature to decrease unnecessary exported symbols -if(CMAKE_COMPILER_IS_GNUCXX) - # set visibility to hidden to hide symbols, unlesss they're exporeted manually in the code - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall") -endif() +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) # Standard directories for installation +include(create_pkgconfig_file) +include(LXQtCompilerSettings NO_POLICY_SCOPE) find_package(Qt5Core REQUIRED QUIET) -find_package(Qt5LinguistTools REQUIRED QUIET) +#find_package(Qt5LinguistTools REQUIRED QUIET) + + +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SYSSTAT_LIBRARY_NAME "sysstat-qt5") set(HEADER_NAMESPACE "SysStat") @@ -62,43 +59,51 @@ set(SYSSTAT_SRCS netstat.cpp ) -set(SYSSTAT_MOCS - basestat.h - cpustat.h - memstat.h - netstat.h - basestat_p.h - cpustat_p.h - memstat_p.h - netstat_p.h -) - - -# Translations -file(GLOB SYSSTAT_TS_FILES - translations/*.ts -) - -qt5_wrap_cpp(SYSSTAT_CXX ${SYSSTAT_MOCS}) -qt5_add_translation(SYSSTAT_QM_FILES ${SYSSTAT_TS_FILES}) +## Translations +#file(GLOB SYSSTAT_TS_FILES +# translations/*.ts +#) +# +#qt5_add_translation(SYSSTAT_QM_FILES ${SYSSTAT_TS_FILES}) +set(SYSSTAT_QM_FILES "") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() -set(APP_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/share/${SYSSTAT_LIBRARY_NAME}") +set(APP_SHARE_DIR "${CMAKE_INSTALL_DATAROOTDIR}/${SYSSTAT_LIBRARY_NAME}") -include_directories(..) -add_definitions(-DTRANSLATIONS_DIR=\"${APP_SHARE_DIR}\") +#add_definitions(-DTRANSLATIONS_DIR=\"${APP_SHARE_DIR}\") -add_library(${SYSSTAT_LIBRARY_NAME} SHARED ${SYSSTAT_PUBLIC_HDRS} ${SYSSTAT_PRIVATE_HDRS} ${SYSSTAT_SRCS} ${SYSSTAT_CXX} ${SYSSTAT_QM_FILES}) +add_library(${SYSSTAT_LIBRARY_NAME} + SHARED + ${SYSSTAT_PUBLIC_HDRS} + ${SYSSTAT_PRIVATE_HDRS} + ${SYSSTAT_SRCS} + ${SYSSTAT_QM_FILES} +) -target_link_libraries(${SYSSTAT_LIBRARY_NAME} Qt5::Core) +target_link_libraries(${SYSSTAT_LIBRARY_NAME} Qt5::Core) set_target_properties(${SYSSTAT_LIBRARY_NAME} PROPERTIES - VERSION ${SYSSTAT_VERSION} - SOVERSION ${MAJOR_VERSION} + VERSION ${SYSSTAT_VERSION} + SOVERSION ${MAJOR_VERSION} +) + +target_compile_definitions(${SYSSTAT_LIBRARY_NAME} + PRIVATE "MAJOR_VERSION=${MAJOR_VERSION}" + PRIVATE "MINOR_VERSION=${MINOR_VERSION}" + PRIVATE "PATCH_VERSION=${PATCH_VERSION}" + PRIVATE "SYSSTAT_LIBRARY" +) + +target_include_directories(${SYSSTAT_LIBRARY_NAME} + INTERFACE "$" +) + +target_include_directories(${SYSSTAT_LIBRARY_NAME} + INTERFACE "$" ) include(cmake/create_portable_headers.cmake) @@ -107,23 +112,81 @@ create_portable_headers(SYSSTAT_NAMESPACE_HEADERS NAMESPACE "${HEADER_NAMESPACE}/" FILENAMES ${SYSSTAT_PUBLIC_CLASSES} ) -install(TARGETS ${SYSSTAT_LIBRARY_NAME} DESTINATION "${LIB_INSTALL_DIR}") -install(FILES ${SYSSTAT_PUBLIC_HDRS} DESTINATION "${INCLUDE_INSTALL_DIR}/${SYSSTAT_LIBRARY_NAME}") -install(FILES ${SYSSTAT_NAMESPACE_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/${SYSSTAT_LIBRARY_NAME}/${HEADER_NAMESPACE}") -install(FILES ${SYSSTAT_QM_FILES} DESTINATION "${APP_SHARE_DIR}") -include(cmake/create_pkgconfig_file.cmake) -create_pkgconfig_file(${SYSSTAT_LIBRARY_NAME} "SysStat, a Qt-based interface to system statistics") +foreach(h ${SYSSTAT_NAMESPACE_HEADERS}) + get_filename_component(bh ${h} NAME) + configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${SYSSTAT_LIBRARY_NAME}/${HEADER_NAMESPACE}/${bh}" COPYONLY) +endforeach() + +foreach(h ${SYSSTAT_PUBLIC_HDRS}) + get_filename_component(bh ${h} NAME) + configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${SYSSTAT_LIBRARY_NAME}/${bh}" COPYONLY) +endforeach() + +install(TARGETS + ${SYSSTAT_LIBRARY_NAME} + DESTINATION "${CMAKE_INSTALL_LIBDIR}" EXPORT ${SYSSTAT_LIBRARY_NAME}-targets + COMPONENT Runtime +) + +install(FILES + ${SYSSTAT_PUBLIC_HDRS} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${SYSSTAT_LIBRARY_NAME}" + COMPONENT Devel +) + +install(FILES + ${SYSSTAT_NAMESPACE_HEADERS} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${SYSSTAT_LIBRARY_NAME}/${HEADER_NAMESPACE}" + COMPONENT Devel +) + +#install(FILES ${SYSSTAT_QM_FILES} DESTINATION "${APP_SHARE_DIR}") + +export(TARGETS + ${SYSSTAT_LIBRARY_NAME} + FILE "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-targets.cmake" +) + +create_pkgconfig_file( + PACKAGE_NAME ${SYSSTAT_LIBRARY_NAME} + DESCRIPTIVE_NAME ${SYSSTAT_LIBRARY_NAME} + DESCRIPTION "SysStat, a Qt-based interface to system statistics" + INCLUDEDIRS ${SYSSTAT_LIBRARY_NAME} + LIBS ${SYSSTAT_LIBRARY_NAME} + REQUIRES "Qt5Core" + VERSION ${SYSSTAT_VERSION} + INSTALL +) + # cmake config file set(SYSSTAT_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/${SYSSTAT_LIBRARY_NAME}") -configure_file( +configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sysstat-config.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config.cmake" - @ONLY + "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}" +) + +# cmake version config file +write_basic_package_version_file( + "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config-version.cmake" + VERSION ${MAJOR}.${MINOR}.${PATCH} + COMPATIBILITY AnyNewerVersion +) + +install(FILES + "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config.cmake" + "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config-version.cmake" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}" + COMPONENT Devel +) + +install(EXPORT + ${SYSSTAT_LIBRARY_NAME}-targets + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}" + COMPONENT Devel ) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config.cmake" DESTINATION "share/cmake/${SYSSTAT_LIBRARY_NAME}") -install(FILES cmake/sysstat_use.cmake DESTINATION "share/cmake/${SYSSTAT_LIBRARY_NAME}") # building tarball with CPack ------------------------------------------------- include(InstallRequiredSystemLibraries) diff --git a/cmake/LXQtCompilerSettings.cmake b/cmake/LXQtCompilerSettings.cmake new file mode 100644 index 0000000..56d39c1 --- /dev/null +++ b/cmake/LXQtCompilerSettings.cmake @@ -0,0 +1,141 @@ +#============================================================================= +# Copyright 2015 Luís Pereira +# Copyright 2015 Palo Kisa +# Copyright 2013 Hong Jen Yee (PCMan) +# +# 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 copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. +#============================================================================= + +#----------------------------------------------------------------------------- +# Honor visibility properties for all target types. +# +# The ``_VISIBILITY_PRESET`` and +# ``VISIBILITY_INLINES_HIDDEN`` target properties affect visibility +# of symbols during dynamic linking. When first introduced these properties +# affected compilation of sources only in shared libraries, module libraries, +# and executables with the ``ENABLE_EXPORTS`` property set. This +# was sufficient for the basic use cases of shared libraries and executables +# with plugins. However, some sources may be compiled as part of static +# libraries or object libraries and then linked into a shared library later. +# CMake 3.3 and above prefer to honor these properties for sources compiled +# in all target types. This policy preserves compatibility for projects +# expecting the properties to work only for some target types. +# +# The ``OLD`` behavior for this policy is to ignore the visibility properties +# for static libraries, object libraries, and executables without exports. +# The ``NEW`` behavior for this policy is to honor the visibility properties +# for all target types. +# +# This policy was introduced in CMake version 3.3. CMake version +# 3.3.0 warns when the policy is not set and uses ``OLD`` behavior. Use +# the ``cmake_policy()`` command to set it to ``OLD`` or ``NEW`` +# explicitly. +#----------------------------------------------------------------------------- +if(COMMAND CMAKE_POLICY) + if (POLICY CMP0063) + cmake_policy(SET CMP0063 NEW) + endif() +endif() + +#include(CheckCXXCompilerFlag) + +#----------------------------------------------------------------------------- +# Detect Clang compiler +#----------------------------------------------------------------------------- +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(LXQT_COMPILER_IS_CLANGCXX 1) +endif() + + +#----------------------------------------------------------------------------- +# Set visibility to hidden to hide symbols, unless they're exported manually +# in the code +#----------------------------------------------------------------------------- +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + + +#----------------------------------------------------------------------------- +# Disable exceptions +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") +endif() + + +#----------------------------------------------------------------------------- +# Common warning flags +#----------------------------------------------------------------------------- +set(__LXQT_COMMON_WARNING_FLAGS "-Wall") + + +#----------------------------------------------------------------------------- +# Warning flags +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__LXQT_COMMON_WARNING_FLAGS}") +endif() + + +#----------------------------------------------------------------------------- +# Linker flags +# Do not allow undefined symbols +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX) + set(CMAKE_SHARED_LINKER_FLAGS + "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}" + ) + set(CMAKE_MODULE_LINKER_FLAGS + "-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}" + ) +endif() + + +#----------------------------------------------------------------------------- +# CXX11 and CXX0X requirements +#----------------------------------------------------------------------------- +#CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +#CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) +#if(COMPILER_SUPPORTS_CXX11) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +#elseif(COMPILER_SUPPORTS_CXX0X) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +#else() +# message(FATAL "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. C++11 support is required") +#endif() + + +#----------------------------------------------------------------------------- +# Enable exceptions for an target +# +# lxqt_enable_target_exceptions( +# +# ) +# +#----------------------------------------------------------------------------- +function(lxqt_enable_target_exceptions target mode) + target_compile_options(${target} ${mode} + "$<$,$>:-fexceptions>" + ) +endfunction() diff --git a/cmake/create_pkgconfig_file.cmake b/cmake/create_pkgconfig_file.cmake index 456f3a1..b218cef 100644 --- a/cmake/create_pkgconfig_file.cmake +++ b/cmake/create_pkgconfig_file.cmake @@ -1,34 +1,245 @@ +#============================================================================= +# Copyright 2015 Luís Pereira # -# Write a pkg-config pc file for given "name" with "decription" -# Arguments: -# name: a library name (withoud "lib" prefix and "so" suffixes -# desc: a desription string +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: # -macro (create_pkgconfig_file name desc) - set(_pkgfname "${CMAKE_CURRENT_BINARY_DIR}/${name}.pc") - #message(STATUS "${name}: writing pkgconfig file ${_pkgfname}") - - file(WRITE "${_pkgfname}" - "# file generated by LXQt cmake build\n" - "prefix=${CMAKE_INSTALL_PREFIX}\n" - "libdir=\${prefix}/lib${LIB_SUFFIX}\n" - "includedir=\${prefix}/include\n" - "\n" - "Name: ${name}\n" - "Description: ${desc}\n" - "Version: ${SYSSTAT_VERSION}\n" - "Requires: Qt5Core\n" - "Libs: -L\${libdir} -l${name}\n" - "Cflags: -I\${includedir}\n" - "\n" +# 1. Redistributions of source code must retain the copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. +#=============================================================================# + +# create_pkgconfig_file(PACKAGE_NAME +# VERSION +# [PREFIX ] +# [EXEC_PREFIX ] +# [INCLUDEDIR_PREFIX ] +# [INCLUDEDIRS ... ] +# [LIBDIR_PREFIX ] +# [DESCRIPTIVE_NAME ] +# [DESCRIPTION ] +# [URL ] +# [REQUIRES ... ] +# [REQUIRES_PRIVATE ... ] +# [LIB_INSTALLDIR ] +# [CFLAGS ] +# [PATH ] +# [INSTALL]) +# +# +# PACKAGE_NAME and VERSION are mandatory. Everything else is optional + +include(CMakeParseArguments) +include(GNUInstallDirs) + +function(create_pkgconfig_file) + set(options INSTALL) + set(oneValueArgs + PACKAGE_NAME + PREFIX + EXEC_PREFIX + INCLUDEDIR_PREFIX + LIBDIR_PREFIX + DESCRIPTIVE_NAME + DESCRIPTION + URL + VERSION + PATH + ) + set(multiValueArgs + INCLUDEDIRS + REQUIRES + REQUIRES_PRIVATE + CONFLICTS + CFLAGS + LIBS + LIBS_PRIVATE ) - # FreeBSD loves to install files to different locations - # http://www.freebsd.org/doc/handbook/dirstructure.html - if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") - install(FILES ${_pkgfname} DESTINATION libdata/pkgconfig) + cmake_parse_arguments(USER "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (USER_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to create_pkgconfig_file(): \"${USER_UNPARSED_ARGUMENTS}\"") + endif() + + # Check for mandatory args. Abort if not set + if (NOT DEFINED USER_PACKAGE_NAME) + message(FATAL_ERROR "Required argument PACKAGE_NAME missing in generate_pkgconfig_file() call") + else() + set(_PKGCONFIG_PACKAGE_NAME "${USER_PACKAGE_NAME}") + endif() + + if (NOT DEFINED USER_VERSION) + message(FATAL_ERROR "Required argument VERSION missing in generate_pkgconfig_file() call") + else() + set(_PKGCONFIG_VERSION "${USER_VERSION}") + endif() + + + # Optional args + if (NOT DEFINED USER_PREFIX) + set(_PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") + endif() + + if (NOT DEFINED USER_EXEC_PREFIX) + set(_PKGCONFIG_EXEC_PREFIX "\${prefix}") + endif() + + if (NOT DEFINED USER_INCLUDEDIR_PREFIX) + set(_PKGCONFIG_INCLUDEDIR_PREFIX "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + endif() + + if (NOT DEFINED USER_LIBDIR_PREFIX) + set(_PKGCONFIG_LIBDIR_PREFIX "\${prefix}/${CMAKE_INSTALL_LIBDIR}") + endif() + + if (NOT DEFINED USER_DESCRIPTIVE_NAME) + set(_PKGCONFIG_DESCRIPTIVE_NAME "") else() - install(FILES ${_pkgfname} DESTINATION lib${LIB_SUFFIX}/pkgconfig) + set(_PKGCONFIG_DESCRIPTIVE_NAME "${USER_DESCRIPTIVE_NAME}") + endif() + + if (DEFINED USER_INCLUDEDIRS) + set(tmp "") + foreach(dir ${USER_INCLUDEDIRS}) + if (NOT IS_ABSOLUTE "${dir}") + list(APPEND tmp "-I\${includedir}/${dir}") + endif() + endforeach() + string(REPLACE ";" " " _INCLUDEDIRS "${tmp}") + endif() + + if (DEFINED USER_REQUIRES) + string(REPLACE ";" ", " _PKGCONFIG_REQUIRES "${USER_REQUIRES}") + endif() + + if (DEFINED USER_REQUIRES_PRIVATE) + string(REPLACE ";" ", " _PKGCONFIG_REQUIRES_PRIVATE "${USER_REQUIRES_PRIVATE}") + else() + set(_PKGCONFIG_REQUIRES_PRIVATE "") + endif() + + if (NOT DEFINED USER_CFLAGS) + set(_PKGCONFIG_CFLAGS "-I\${includedir} ${_INCLUDEDIRS}") endif() -endmacro() + if (NOT DEFINED USER_LIBS) + set(_PKGCONFIG_LIBS "-L\${libdir}") + else() + set(tmp "-L\${libdir}") + set(_libs "${USER_LIBS}") + foreach(lib ${_libs}) + list(APPEND tmp "-l${lib}") + endforeach() + string(REPLACE ";" " " _PKGCONFIG_LIBS "${tmp}") + endif() + + if (NOT DEFINED USER_LIBS_PRIVATE) + set(PKGCONFIG_LIBS "-L\${libdir}") + else() + set(tmp "") + set(_libs "${USER_LIBS_PRIVATE}") + foreach(lib ${_libs}) + list(APPEND tmp "-l${lib}") + endforeach() + string(REPLACE ";" " " _PKGCONFIG_LIBS_PRIVATE "${tmp}") + endif() + + if (DEFINED USER_DESCRIPTION) + set(_PKGCONFIG_DESCRIPTION "${USER_DESCRIPTION}") + else() + set(_PKGCONFIG_DESCRIPTION "") + endif() + + if (DEFINED USER_URL) + set(_PKFCONFIG_URL "${USER_URL}") + else() + set(_PKGCONFIG_URL "") + endif() + + if (NOT DEFINED USER_PATH) + set(_PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${_PKGCONFIG_PACKAGE_NAME}.pc") + else() + if (IS_ABSOLUTE "${USER_PATH}") + set(_PKGCONFIG_FILE "${USER_PATH}/${_PKGCONFIG_PACKAGE_NAME}.pc") + else() + set(_PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${USER_PATH}/${_PKGCONFIG_PACKAGE_NAME}.pc") + endif() + endif() + + # Write the .pc file + FILE(WRITE "${_PKGCONFIG_FILE}" + "# file generated by create_pkgconfig_file()\n" + "prefix=${_PKGCONFIG_PREFIX}\n" + "exec_prefix=${_PKGCONFIG_EXEC_PREFIX}\n" + "libdir=${_PKGCONFIG_LIBDIR_PREFIX}\n" + "includedir=${_PKGCONFIG_INCLUDEDIR_PREFIX}\n" + "\n" + "Name: ${_PKGCONFIG_DESCRIPTIVE_NAME}\n" + ) + + if (NOT "${_PKGCONFIG_DESCRIPTION}" STREQUAL "") + FILE(APPEND ${_PKGCONFIG_FILE} + "Description: ${_PKGCONFIG_DESCRIPTION}\n" + ) + endif() + + if (NOT "${_PKGCONFIG_URL}" STREQUAL "") + FILE(APPEND ${_PKGCONFIG_FILE} "URL: ${_PKGCONFIG_URL}\n") + endif() + + FILE(APPEND ${_PKGCONFIG_FILE} "Version: ${_PKGCONFIG_VERSION}\n") + + if (NOT "${_PKGCONFIG_REQUIRES}" STREQUAL "") + FILE(APPEND ${_PKGCONFIG_FILE} "Requires: ${_PKGCONFIG_REQUIRES}\n") + endif() + + if (NOT "${_PKGCONFIG_REQUIRES_PRIVATE}" STREQUAL "") + FILE(APPEND ${_PKGCONFIG_FILE} + "Requires.private: ${_PKGCONFIG_REQUIRES_PRIVATE}\n" + ) + endif() + + + FILE(APPEND ${_PKGCONFIG_FILE} + "Cflags: ${_PKGCONFIG_CFLAGS}\n" + "Libs: ${_PKGCONFIG_LIBS}\n" + ) + + if (NOT "${_PKGCONFIG_LIBS_PRIVATE}" STREQUAL "") + FILE(APPEND ${_PKGCONFIG_FILE} + "Libs.private: ${_PKGCONFIG_REQUIRES_PRIVATE}\n" + ) + endif() + + if (DEFINED USER_INSTALL) + # FreeBSD loves to install files to different locations + # http://www.freebsd.org/doc/handbook/dirstructure.html + if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(_PKGCONFIG_INSTALL_DESTINATION "libdata/pkgconfig") + else() + set(_PKGCONFIG_INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + endif() + + # Make the COMPONENT an parameter ? + install(FILES "${_PKGCONFIG_FILE}" + DESTINATION "${_PKGCONFIG_INSTALL_DESTINATION}" + COMPONENT Devel) + endif() +endfunction() diff --git a/cmake/sysstat-config.cmake.in b/cmake/sysstat-config.cmake.in index 99e8aa9..4c34d2d 100644 --- a/cmake/sysstat-config.cmake.in +++ b/cmake/sysstat-config.cmake.in @@ -3,32 +3,21 @@ # The module defines the following variables # # SYSSTAT_FOUND - Set to TRUE if all of the above has been found -# -# SYSSTAT_INCLUDE_DIR - The lxqt include directory -# -# SYSSTAT_INCLUDE_DIRS - The lxqt and the Qt include directory, for use with INCLUDE_DIRECTORIES() -# -# SYSSTAT_LIBRARY_DIRS - The lxqt and the Qt library directory -# -# SYSSTAT_LIBRARIES - The libraries needed to use lxqt -# -# SYSSTAT_USE_FILE - The variable SYSSTAT_USE_FILE is set which is the path to a CMake file that -# can be included to compile lxqt applications and libraries. It sets up -# the compilation environment for include directories and populates a -# SYSSTAT_LIBRARIES variable. + + +@PACKAGE_INIT@ set(SYSSTAT_MAJOR_VERSION @MAJOR_VERSION@) set(SYSSTAT_MINOR_VERSION @MINOR_VERSION@) set(SYSSTAT_PATCH_VERSION @PATCH_VERSION@) set(SYSSTAT_VERSION @SYSSTAT_VERSION@) -set(SYSSTAT_INCLUDE_DIR @SYSSTAT_INCLUDE_DIR@) -set(SYSSTAT_LIBRARY @SYSSTAT_LIBRARY_NAME@) +include(CMakeFindDependencyMacro) -set(SYSSTAT_LIBRARIES ${SYSSTAT_LIBRARY}) -set(SYSSTAT_INCLUDE_DIRS "${SYSSTAT_INCLUDE_DIR}") -set(SYSSTAT_LIBRARY_DIRS @CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@) -set(SYSSTAT_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/sysstat_use.cmake") -set(SYSSTAT_FOUND 1) +find_dependency(Qt5Core REQUIRED QUIET) +find_dependency(Qt5LinguistTools REQUIRED QUIET) -mark_as_advanced(SYSSTAT_LIBRARY SYSSTAT_INCLUDE_DIR) +if (CMAKE_VERSION VERSION_GREATER 2.8.12) + cmake_policy(SET CMP0024 OLD) +endif() +include("${CMAKE_CURRENT_LIST_DIR}/@SYSSTAT_LIBRARY_NAME@-targets.cmake") diff --git a/cmake/sysstat_use.cmake b/cmake/sysstat_use.cmake deleted file mode 100644 index 042679c..0000000 --- a/cmake/sysstat_use.cmake +++ /dev/null @@ -1 +0,0 @@ -link_directories(${SYSSTAT_LIBRARY_DIRS}) diff --git a/memstat.cpp b/memstat.cpp index da20117..074fbc8 100644 --- a/memstat.cpp +++ b/memstat.cpp @@ -46,12 +46,12 @@ MemStatPrivate::~MemStatPrivate() void MemStatPrivate::timeout() { - qulonglong memTotal; - qulonglong memFree; - qulonglong memBuffers; - qulonglong memCached; - qulonglong swapTotal; - qulonglong swapFree; + qulonglong memTotal = 0; + qulonglong memFree = 0; + qulonglong memBuffers = 0; + qulonglong memCached = 0; + qulonglong swapTotal = 0; + qulonglong swapFree = 0; foreach (QString row, readAllFile("/proc/meminfo").split(QChar('\n'), QString::SkipEmptyParts)) {