2015-01-18 08:31:04 -05:00
|
|
|
# vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
|
|
|
|
#
|
|
|
|
# Copyright 2012 Matthew McCormick
|
|
|
|
# Copyright 2015 Pawel 'l0ner' Soltys
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
2018-04-14 09:47:35 -04:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2009-09-09 02:51:47 -04:00
|
|
|
|
2015-01-07 08:31:49 -05:00
|
|
|
### General Package stuff
|
2015-01-20 08:11:20 -05:00
|
|
|
project(tmux-mem-cpu-load)
|
2015-01-20 08:11:40 -05:00
|
|
|
set(tmux-mem-cpu-load_VERSION_MAJOR 3)
|
2023-05-12 06:29:08 -04:00
|
|
|
set(tmux-mem-cpu-load_VERSION_MINOR 8)
|
2024-05-22 12:04:44 -04:00
|
|
|
set(tmux-mem-cpu-load_VERSION_PATCH 1)
|
2015-01-18 08:51:27 -05:00
|
|
|
#Compute full version string
|
|
|
|
set(tmux-mem-cpu-load_VERSION
|
|
|
|
${tmux-mem-cpu-load_VERSION_MAJOR}.${tmux-mem-cpu-load_VERSION_MINOR}.${tmux-mem-cpu-load_VERSION_PATCH})
|
2014-04-14 14:51:46 -04:00
|
|
|
|
2015-01-18 10:59:19 -05:00
|
|
|
# Check whether we have support for c++11 in compiler and fail if we don't
|
2022-02-17 15:19:02 -05:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2015-01-18 10:59:19 -05:00
|
|
|
|
2014-04-14 14:51:46 -04:00
|
|
|
# generate header file to handle version
|
|
|
|
configure_file(
|
2015-01-20 08:04:02 -05:00
|
|
|
"${PROJECT_SOURCE_DIR}/common/version.h.in" "${PROJECT_BINARY_DIR}/version.h"
|
2015-01-18 08:31:04 -05:00
|
|
|
)
|
2009-09-09 02:51:47 -04:00
|
|
|
|
2015-01-18 14:04:28 -05:00
|
|
|
# set build type
|
2009-09-09 02:51:47 -04:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2013-07-15 19:23:11 -04:00
|
|
|
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING
|
2015-01-18 08:31:04 -05:00
|
|
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
|
|
|
FORCE)
|
2009-09-09 02:51:47 -04:00
|
|
|
endif(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
2014-04-14 14:51:46 -04:00
|
|
|
# detect system type
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
2015-01-19 21:50:47 -05:00
|
|
|
message(STATUS "Linux detected")
|
2015-02-19 14:25:43 -05:00
|
|
|
set(METER_SOURCES "linux/memory.cc" "linux/cpu.cc" "common/load.cc")
|
2015-01-17 17:23:21 -05:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
2015-01-19 21:50:47 -05:00
|
|
|
message(STATUS "Darwin detected")
|
2015-02-19 14:25:43 -05:00
|
|
|
set(METER_SOURCES "osx/memory.cc" "osx/cpu.cc" "common/load.cc")
|
2015-01-17 17:23:21 -05:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
2015-01-20 09:08:47 -05:00
|
|
|
message(STATUS "FreeBSD detected")
|
2015-02-19 14:25:43 -05:00
|
|
|
set(METER_SOURCES "freebsd/memory.cc" "freebsd/cpu.cc" "common/load.cc")
|
2015-01-17 17:23:21 -05:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
2015-01-20 09:08:47 -05:00
|
|
|
message(STATUS "OpenBSD detected")
|
2015-02-19 14:25:43 -05:00
|
|
|
set(METER_SOURCES "openbsd/memory.cc" "openbsd/cpu.cc" "common/load.cc")
|
2015-01-26 13:48:56 -05:00
|
|
|
if(CMAKE_SYSTEM_VERSION VERSION_LESS 5.7)
|
|
|
|
add_definitions(-DOPENBSD_WORKAROUND=1)
|
|
|
|
endif()
|
2015-02-16 17:29:27 -05:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
2018-04-23 21:47:03 -04:00
|
|
|
message(STATUS "NetBSD detected")
|
2015-02-19 14:25:43 -05:00
|
|
|
set(METER_SOURCES "netbsd/memory.cc" "netbsd/cpu.cc" "common/load.cc")
|
2018-04-23 21:47:03 -04:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
message(STATUS "Windows detected")
|
|
|
|
set(METER_SOURCES "windows/memory.cc" "windows/cpu.cc" "windows/load.cc")
|
2015-01-17 17:23:21 -05:00
|
|
|
else()
|
2018-04-14 09:47:35 -04:00
|
|
|
message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} Cannot be compiled on this system")
|
2015-01-20 09:08:47 -05:00
|
|
|
message(FATAL_ERROR "Cannot be compiled on this system")
|
2014-04-14 14:51:46 -04:00
|
|
|
endif()
|
|
|
|
|
2015-01-07 14:57:25 -05:00
|
|
|
# set common source files
|
2016-04-14 06:18:10 -04:00
|
|
|
set(COMMON_SOURCES "common/main.cc" "common/memory.cc" "common/graph.cc" "common/powerline.cc")
|
2015-01-07 14:57:25 -05:00
|
|
|
|
|
|
|
add_executable(tmux-mem-cpu-load ${COMMON_SOURCES} ${METER_SOURCES})
|
2018-04-14 09:47:35 -04:00
|
|
|
# add binary tree so we find version.h
|
2018-04-23 21:47:03 -04:00
|
|
|
target_include_directories(tmux-mem-cpu-load PUBLIC "${PROJECT_BINARY_DIR}")
|
|
|
|
target_include_directories(tmux-mem-cpu-load PUBLIC "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/common")
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
target_link_libraries(tmux-mem-cpu-load Pdh)
|
|
|
|
endif()
|
2015-01-18 10:59:19 -05:00
|
|
|
install(TARGETS tmux-mem-cpu-load RUNTIME DESTINATION bin)
|
2013-06-09 22:50:03 -04:00
|
|
|
|
2015-01-19 21:54:35 -05:00
|
|
|
include(CTest)
|
|
|
|
if(BUILD_TESTING)
|
|
|
|
add_test(NAME usage
|
|
|
|
COMMAND tmux-mem-cpu-load -h
|
|
|
|
)
|
2013-06-09 22:50:03 -04:00
|
|
|
|
2015-01-19 21:54:35 -05:00
|
|
|
add_test(NAME no_arguments
|
|
|
|
COMMAND tmux-mem-cpu-load
|
|
|
|
)
|
2013-06-09 22:50:03 -04:00
|
|
|
|
2015-01-19 21:54:35 -05:00
|
|
|
add_test(NAME custom_interval
|
|
|
|
COMMAND tmux-mem-cpu-load -i 3
|
|
|
|
)
|
2015-01-08 14:04:27 -05:00
|
|
|
|
2015-01-19 21:54:35 -05:00
|
|
|
add_test(NAME no_cpu_graph
|
|
|
|
COMMAND tmux-mem-cpu-load -g 0
|
|
|
|
)
|
2015-01-18 09:07:11 -05:00
|
|
|
|
2015-01-19 21:54:35 -05:00
|
|
|
add_test(NAME colors
|
|
|
|
COMMAND tmux-mem-cpu-load --colors
|
|
|
|
)
|
2013-06-09 22:50:03 -04:00
|
|
|
|
2016-06-26 09:47:02 -04:00
|
|
|
add_test(NAME colors_short
|
|
|
|
COMMAND tmux-mem-cpu-load -c
|
|
|
|
)
|
|
|
|
|
2016-07-31 21:59:52 -04:00
|
|
|
add_test(NAME powerline-right
|
|
|
|
COMMAND tmux-mem-cpu-load --powerline-right
|
|
|
|
)
|
|
|
|
|
|
|
|
add_test(NAME powerline-left
|
|
|
|
COMMAND tmux-mem-cpu-load --powerline-left
|
2016-03-05 05:19:31 -05:00
|
|
|
)
|
|
|
|
|
2015-01-19 21:54:35 -05:00
|
|
|
add_test(NAME invalid_status_interval
|
|
|
|
COMMAND tmux-mem-cpu-load -i -1
|
|
|
|
)
|
2013-06-09 22:50:03 -04:00
|
|
|
|
2015-01-19 21:54:35 -05:00
|
|
|
add_test(NAME invalid_graph_lines
|
|
|
|
COMMAND tmux-mem-cpu-load --graph_lines -2
|
|
|
|
)
|
2013-06-09 22:50:03 -04:00
|
|
|
|
2015-01-19 22:51:14 -05:00
|
|
|
add_test(NAME old_option_specification
|
|
|
|
COMMAND tmux-mem-cpu-load 2 8
|
|
|
|
)
|
|
|
|
|
2016-02-10 15:49:49 -05:00
|
|
|
add_test(NAME memory_mode_free_memory
|
|
|
|
COMMAND tmux-mem-cpu-load -m 1
|
|
|
|
)
|
|
|
|
|
|
|
|
add_test(NAME memory_mode_used_percentage
|
|
|
|
COMMAND tmux-mem-cpu-load -m 2
|
|
|
|
)
|
|
|
|
|
2016-05-06 03:03:18 -04:00
|
|
|
add_test(NAME averages_count_0
|
|
|
|
COMMAND tmux-mem-cpu-load -a 0
|
|
|
|
)
|
|
|
|
|
|
|
|
add_test(NAME averages_count_1
|
|
|
|
COMMAND tmux-mem-cpu-load -a 1
|
|
|
|
)
|
|
|
|
|
|
|
|
add_test(NAME averages_count_2
|
|
|
|
COMMAND tmux-mem-cpu-load -a 2
|
|
|
|
)
|
|
|
|
|
|
|
|
add_test(NAME averages_count_3
|
|
|
|
COMMAND tmux-mem-cpu-load -a 3
|
|
|
|
)
|
|
|
|
|
2016-06-26 09:47:02 -04:00
|
|
|
add_test(NAME cpu_mode_0
|
|
|
|
COMMAND tmux-mem-cpu-load --cpu-mode 0
|
|
|
|
)
|
|
|
|
|
|
|
|
add_test(NAME cpu_mode_1
|
|
|
|
COMMAND tmux-mem-cpu-load --cpu-mode 1
|
|
|
|
)
|
|
|
|
|
|
|
|
add_test(NAME cpu_mode_short_0
|
|
|
|
COMMAND tmux-mem-cpu-load -t 0
|
|
|
|
)
|
|
|
|
|
|
|
|
add_test(NAME cpu_mode_short_1
|
|
|
|
COMMAND tmux-mem-cpu-load -t 1
|
|
|
|
)
|
|
|
|
|
2015-01-19 21:54:35 -05:00
|
|
|
set_tests_properties(usage
|
2013-06-09 22:50:03 -04:00
|
|
|
invalid_status_interval
|
|
|
|
invalid_graph_lines
|
2015-01-19 22:51:14 -05:00
|
|
|
old_option_specification
|
2015-01-19 21:54:35 -05:00
|
|
|
PROPERTIES WILL_FAIL TRUE)
|
2013-06-09 22:50:03 -04:00
|
|
|
endif()
|