2009-09-09 02:51:47 -04:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
if(COMMAND cmake_policy)
|
|
|
|
cmake_policy(VERSION 2.6)
|
|
|
|
endif(COMMAND cmake_policy)
|
|
|
|
|
2015-01-07 08:31:49 -05:00
|
|
|
### General Package stuff
|
|
|
|
|
2010-02-24 19:04:41 -05:00
|
|
|
project( tmux-mem-cpu-load )
|
2015-01-07 08:31:49 -05:00
|
|
|
set(VERSION_MAJOR 2)
|
|
|
|
set(VERSION_MINOR 3)
|
|
|
|
set(VERSION_PATCH 0)
|
2014-04-14 14:51:46 -04:00
|
|
|
|
|
|
|
# generate header file to handle version
|
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/version.h.in"
|
|
|
|
"${PROJECT_SOURCE_DIR}/version.h"
|
|
|
|
)
|
2009-09-09 02:51:47 -04:00
|
|
|
|
2015-01-07 14:57:25 -05:00
|
|
|
# set buold 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
|
2009-09-09 02:51:47 -04:00
|
|
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
|
|
|
FORCE)
|
|
|
|
endif(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
2014-04-14 14:51:46 -04:00
|
|
|
# detect system type
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
message( "Linux detected")
|
|
|
|
SET( METER_SOURCES "linux/memory.cc" "linux/cpu.cc" "linux/load.cc" )
|
|
|
|
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
2015-01-07 08:15:28 -05:00
|
|
|
# Mac OS X source setting will go here
|
2014-04-14 14:51:46 -04:00
|
|
|
message( "Darwin detected")
|
|
|
|
SET( METER_SOURCES "osx/memory.cc" "osx/cpu.cc" "osx/load.cc" )
|
|
|
|
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
2015-01-07 08:15:28 -05:00
|
|
|
# FreeBSD STUFF HERE
|
2014-04-14 14:51:46 -04:00
|
|
|
message( "FreeBSD detected")
|
2015-01-10 12:34:37 -05:00
|
|
|
message( WARNING "FreeBSD is still experimental!" )
|
|
|
|
SET( METER_SOURCES "bsd/memory_freebsd.cc" "bsd/cpu.cc" "bsd/load.cc" )
|
2014-04-14 14:51:46 -04:00
|
|
|
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
2015-01-07 08:15:28 -05:00
|
|
|
# OpenBSD Stuff Here
|
2014-04-14 14:51:46 -04:00
|
|
|
message( "OpenBSD detected")
|
2015-01-12 09:21:43 -05:00
|
|
|
message( FATAL_ERROR "OpenBSD is not supported! See bsd/openBSD.txt for more
|
|
|
|
info" )
|
2015-01-10 12:34:37 -05:00
|
|
|
SET( METER_SOURCES "bsd/memory_openbsd.cc" "bsd/cpu.cc" "bsd/load.cc" )
|
2015-01-07 08:15:28 -05:00
|
|
|
ELSE()
|
2014-04-14 14:51:46 -04:00
|
|
|
message( FATAL_ERROR "Cannot be compiled on this system" )
|
|
|
|
endif()
|
|
|
|
|
2015-01-07 14:57:25 -05:00
|
|
|
# set common source files
|
|
|
|
SET( COMMON_SOURCES "tmux-mem-cpu-load.cpp" "graph.cc" "argParse/argParse.cc" )
|
|
|
|
|
2014-04-14 14:51:46 -04:00
|
|
|
# compiler flags
|
2015-01-17 10:30:31 -05:00
|
|
|
if (CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
execute_process(COMMAD ${CMAKE_C_COMPILER} -dumpversion
|
|
|
|
OUTPUT_VARIABLE GCC_VERSION)
|
|
|
|
if (GCC_VERSION VERSION_EQUAL 4.6)
|
|
|
|
SET( GCC_COVERAGE_COMPILE_FLAGS "-std=c++0x " )
|
|
|
|
elseif (GCC_VERSION GREATER 4.6)
|
|
|
|
SET( GCC_COVERAGE_COMPILE_FLAGS "-std=c++11 " )
|
|
|
|
else()
|
|
|
|
message( FATAL_ERROR "You need gcc version >= 4.6")
|
|
|
|
endif()
|
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
SET( GCC_COVERAGE_COMPILE_FLAGS "-std=c++11 " )
|
|
|
|
else()
|
|
|
|
message( WARNING "Untested compiler detected. You may need to set c++11
|
|
|
|
support manually through CMakeList.txt file")
|
|
|
|
SET( GCC_COVERAGE_COMPILE_FLAGS "" )
|
|
|
|
endif()
|
2014-04-14 14:51:46 -04:00
|
|
|
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
|
|
|
|
|
|
|
|
# add binary tree so we find version.h
|
2015-01-07 14:57:25 -05:00
|
|
|
include_directories("${PROJECT_BINARY_DIR}" )
|
2013-04-30 06:38:39 -04:00
|
|
|
|
2015-01-07 14:57:25 -05:00
|
|
|
add_executable(tmux-mem-cpu-load ${COMMON_SOURCES} ${METER_SOURCES})
|
2014-04-14 14:51:46 -04:00
|
|
|
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 )
|
|
|
|
|
|
|
|
add_test( NAME no_arguments
|
|
|
|
COMMAND tmux-mem-cpu-load )
|
|
|
|
|
2015-01-08 14:04:27 -05:00
|
|
|
add_test( NAME custom_interval
|
|
|
|
COMMAND tmux-mem-cpu-load -i 3 )
|
|
|
|
|
2013-06-09 22:50:03 -04:00
|
|
|
add_test( NAME colors
|
|
|
|
COMMAND tmux-mem-cpu-load --colors )
|
|
|
|
|
|
|
|
add_test( NAME invalid_status_interval
|
2015-01-08 13:52:46 -05:00
|
|
|
COMMAND tmux-mem-cpu-load -i -1 )
|
2013-06-09 22:50:03 -04:00
|
|
|
|
|
|
|
add_test( NAME invalid_graph_lines
|
2015-01-08 14:04:27 -05:00
|
|
|
COMMAND tmux-mem-cpu-load --graph_lines -2 )
|
2013-06-09 22:50:03 -04:00
|
|
|
|
|
|
|
set_tests_properties( usage
|
|
|
|
invalid_status_interval
|
|
|
|
invalid_graph_lines
|
|
|
|
PROPERTIES WILL_FAIL TRUE )
|
|
|
|
endif()
|