tmux-mem-cpu-load/CMakeLists.txt

86 lines
2.4 KiB
CMake
Raw Normal View History

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)
project( tmux-mem-cpu-load )
2014-04-14 14:51:46 -04:00
set(tmux-mem-cpu-load_VERSION_MAJOR 2)
set(tmux-mem-cpu-load_VERSION_MINOR 3)
set(tmux-mem-cpu-load_VERSION_PATCH 0)
# 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
if(NOT CMAKE_BUILD_TYPE)
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")
message( "Darwin detected")
SET( METER_SOURCES "osx/memory.cc" "osx/cpu.cc" "osx/load.cc" )
# Mac OS X source setting will go here
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
message( "FreeBSD detected")
# FreeBSD STUFF HERE
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
message( "OpenBSD detected")
# OpenBSD Stuff Here
ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
message( FATAL_ERROR "Cannot be compiled on this system" )
endif()
# Search for boost
# will be needed later
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_SUE_STATIC_RUTIME OFF)
find_package(Boost 1.52.0 REQUIRED COMPONENTS filesystem program_options system)
# compiler flags
SET( GCC_COVERAGE_COMPILE_FLAGS "-std=c++11 " )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
# add binary tree so we find version.h
include_directories("${PROJECT_BINARY_DIR}" ${Boost_INCLUDE_DIRS})
2014-04-14 14:51:46 -04:00
add_executable(tmux-mem-cpu-load tmux-mem-cpu-load.cpp ${METER_SOURCES})
target_link_libraries(tmux-mem-cpu-load ${Boost_LIBRARIES})
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 )
add_test( NAME colors
COMMAND tmux-mem-cpu-load --colors )
add_test( NAME arguments
COMMAND tmux-mem-cpu-load --colors 1 4 )
add_test( NAME invalid_status_interval
COMMAND tmux-mem-cpu-load -1 4 )
add_test( NAME invalid_graph_lines
COMMAND tmux-mem-cpu-load 1 -4 )
set_tests_properties( usage
invalid_status_interval
invalid_graph_lines
PROPERTIES WILL_FAIL TRUE )
endif()