tmux-mem-cpu-load/CMakeLists.txt

132 lines
4.0 KiB
CMake
Raw Normal View History

# 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.
#
2009-09-09 02:51:47 -04:00
cmake_minimum_required(VERSION 2.6)
if(COMMAND cmake_policy)
cmake_policy(VERSION 2.6)
2009-09-09 02:51:47 -04:00
endif(COMMAND cmake_policy)
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)
2015-02-19 22:42:29 -05:00
set(tmux-mem-cpu-load_VERSION_MINOR 2)
2015-03-01 19:23:55 -05:00
set(tmux-mem-cpu-load_VERSION_PATCH 1)
#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
# Check whether we have support for c++11 in compiler and fail if we don't
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
2015-01-20 08:11:20 -05:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
2015-01-20 08:11:20 -05:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
2015-01-20 08:11:20 -05:00
message(FATAL_ERROR
"Compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} has no C++11 support.")
endif()
2014-04-14 14:51:46 -04:00
# generate header file to handle version
configure_file(
"${PROJECT_SOURCE_DIR}/common/version.h.in" "${PROJECT_BINARY_DIR}/version.h"
)
2009-09-09 02:51:47 -04:00
# set build type
2009-09-09 02:51:47 -04:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING
"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")
message(STATUS "Linux detected")
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")
message(STATUS "Darwin detected")
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")
message(STATUS "FreeBSD detected")
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")
# OpenBSD Stuff Here
message(STATUS "OpenBSD detected")
set(METER_SOURCES "openbsd/memory.cc" "openbsd/cpu.cc" "common/load.cc")
if(CMAKE_SYSTEM_VERSION VERSION_LESS 5.7)
add_definitions(-DOPENBSD_WORKAROUND=1)
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set(METER_SOURCES "netbsd/memory.cc" "netbsd/cpu.cc" "common/load.cc")
2015-01-17 17:23:21 -05:00
else()
message(FATAL_ERROR "Cannot be compiled on this system")
2014-04-14 14:51:46 -04:00
endif()
# set common source files
set(COMMON_SOURCES "common/main.cc" "common/graph.cc")
2014-04-14 14:51:46 -04:00
# add binary tree so we find version.h
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/common")
add_executable(tmux-mem-cpu-load ${COMMON_SOURCES} ${METER_SOURCES})
install(TARGETS tmux-mem-cpu-load RUNTIME DESTINATION bin)
2013-06-09 22:50:03 -04:00
include(CTest)
if(BUILD_TESTING)
add_test(NAME usage
COMMAND tmux-mem-cpu-load -h
)
2013-06-09 22:50:03 -04:00
add_test(NAME no_arguments
COMMAND tmux-mem-cpu-load
)
2013-06-09 22:50:03 -04:00
add_test(NAME custom_interval
COMMAND tmux-mem-cpu-load -i 3
)
2015-01-08 14:04:27 -05:00
add_test(NAME no_cpu_graph
COMMAND tmux-mem-cpu-load -g 0
)
2015-01-18 09:07:11 -05:00
add_test(NAME colors
COMMAND tmux-mem-cpu-load --colors
)
2013-06-09 22:50:03 -04:00
add_test(NAME invalid_status_interval
COMMAND tmux-mem-cpu-load -i -1
)
2013-06-09 22:50:03 -04:00
add_test(NAME invalid_graph_lines
COMMAND tmux-mem-cpu-load --graph_lines -2
)
2013-06-09 22:50:03 -04:00
add_test(NAME old_option_specification
COMMAND tmux-mem-cpu-load 2 8
)
set_tests_properties(usage
2013-06-09 22:50:03 -04:00
invalid_status_interval
invalid_graph_lines
old_option_specification
PROPERTIES WILL_FAIL TRUE)
2013-06-09 22:50:03 -04:00
endif()