forked from thewtex/tmux-mem-cpu-load
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (65 loc) · 2.55 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 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.
#
cmake_minimum_required(VERSION 2.6)
### General Package stuff
project(tmux-host-stats)
set(tmux-host-stats_VERSION_MAJOR 3)
set(tmux-host-stats_VERSION_MINOR 4)
set(tmux-host-stats_VERSION_PATCH 0)
#Compute full version string
set(tmux-host-stats_VERSION
${tmux-host-stats_VERSION_MAJOR}.${tmux-host-stats_VERSION_MINOR}.${tmux-host-stats_VERSION_PATCH})
# 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)
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_ERROR
"Compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} has no C++11 support.")
endif()
# generate header file to handle version
configure_file(
"${PROJECT_SOURCE_DIR}/src/version.h.in" "${PROJECT_BINARY_DIR}/version.h"
)
# set build type
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)
endif(NOT CMAKE_BUILD_TYPE)
# detect system type
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
message(STATUS "Linux detected")
set(METER_SOURCES "src/stats.linux.cc")
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
message(STATUS "Darwin detected")
set(METER_SOURCES "src/stats.osx.cc")
else()
message(FATAL_ERROR "Cannot be compiled on this system")
endif()
# set common source files
set(COMMON_SOURCES "src/main.cc")
# add binary tree so we find version.h
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/src")
add_executable(tmux-host-stats ${COMMON_SOURCES} ${METER_SOURCES})
install(TARGETS tmux-host-stats RUNTIME DESTINATION bin)