forked from hyperic/sigar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
113 lines (93 loc) · 2.88 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
## sigar has some base files + a set of platform specific files
MESSAGE(STATUS "CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}")
INCLUDE_DIRECTORIES(../include/)
INCLUDE(CheckCSourceCompiles)
MACRO (CHECK_STRUCT_MEMBER _STRUCT _MEMBER _HEADER _RESULT)
SET(_INCLUDE_FILES)
FOREACH (it ${_HEADER})
SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
ENDFOREACH (it)
SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE "
${_INCLUDE_FILES}
int main()
{
static ${_STRUCT} tmp;
if (sizeof(tmp.${_MEMBER}))
return 0;
return 0;
}
")
CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
ENDMACRO (CHECK_STRUCT_MEMBER)
## linux
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
SET(SIGAR_SRC os/linux/linux_sigar.c)
INCLUDE_DIRECTORIES(os/linux/)
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
## macosx, freebsd
IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
SET(SIGAR_SRC os/darwin/darwin_sigar.c)
INCLUDE_DIRECTORIES(os/darwin/)
IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
INCLUDE_DIRECTORIES(/Developer/Headers/FlatCarbon/)
ADD_DEFINITIONS(-DDARWIN)
SET(SIGAR_LINK_FLAGS "-framework CoreServices -framework IOKit")
ELSE(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
## freebsd needs libkvm
SET(SIGAR_LINK_FLAGS "-lkvm")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
## solaris
IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
SET(SIGAR_SRC
os/solaris/solaris_sigar.c
os/solaris/get_mib2.c
os/solaris/kstats.c
os/solaris/procfs.c
)
INCLUDE_DIRECTORIES(os/solaris/)
ADD_DEFINITIONS(-DSOLARIS)
SET(SIGAR_LINK_FLAGS -lkstat -ldl -lnsl -lsocket -lresolv)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
## solaris
IF (CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
SET(SIGAR_SRC os/hpux/hpux_sigar.c)
INCLUDE_DIRECTORIES(os/hpux/)
ADD_DEFINITIONS(-DSIGAR_HPUX)
SET(SIGAR_LINK_FLAGS -lnm)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
## aix
IF (CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
SET(SIGAR_SRC os/aix/aix_sigar.c)
INCLUDE_DIRECTORIES(os/aix/)
SET(SIGAR_LINK_FLAGS -lodm -lcfg)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
IF(WIN32)
ADD_DEFINITIONS(-DSIGAR_SHARED)
SET(SIGAR_SRC os/win32/peb.c os/win32/win32_sigar.c)
INCLUDE_DIRECTORIES(os/win32)
CHECK_STRUCT_MEMBER(MIB_IPADDRROW wType "windows.h;iphlpapi.h" wType_in_MIB_IPADDRROW)
add_definitions(-DHAVE_MIB_IPADDRROW_WTYPE=${wType_in_MIB_IPADDRROW})
ENDIF(WIN32)
SET(SIGAR_SRC ${SIGAR_SRC}
sigar.c
sigar_cache.c
sigar_fileinfo.c
sigar_format.c
sigar_getline.c
sigar_ptql.c
sigar_signal.c
sigar_util.c
)
ADD_LIBRARY(sigar SHARED ${SIGAR_SRC})
IF(WIN32)
TARGET_LINK_LIBRARIES(sigar ws2_32 netapi32 version)
ENDIF(WIN32)
IF(SIGAR_LINK_FLAGS)
SET_TARGET_PROPERTIES(sigar PROPERTIES LINK_FLAGS "${SIGAR_LINK_FLAGS}")
ENDIF(SIGAR_LINK_FLAGS)
INSTALL(TARGETS sigar
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)