1## sigar has some base files + a set of platform specific files
2
3INCLUDE_DIRECTORIES(../include/)
4
5## linux
6IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
7  SET(SIGAR_SRC os/linux/linux_sigar.c)
8
9  INCLUDE_DIRECTORIES(os/linux/)
10ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
11
12## macosx, freebsd
13IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
14  SET(SIGAR_SRC os/darwin/darwin_sigar.c)
15
16  INCLUDE_DIRECTORIES(os/darwin/)
17  IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
18    INCLUDE_DIRECTORIES(/Developer/Headers/FlatCarbon/)
19    ADD_DEFINITIONS(-DDARWIN)
20    SET(SIGAR_LINK_FLAGS "-framework CoreServices -framework IOKit")
21  ELSE(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
22    ## freebsd needs libkvm
23    SET(SIGAR_LINK_FLAGS "-lkvm")
24  ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
25ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
26
27## solaris
28IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
29  SET(SIGAR_SRC
30	os/solaris/solaris_sigar.c
31	os/solaris/get_mib2.c
32	os/solaris/kstats.c
33	os/solaris/procfs.c
34  )
35
36  INCLUDE_DIRECTORIES(os/solaris/)
37  ADD_DEFINITIONS(-DSOLARIS)
38  ADD_DEFINITIONS(-DHAVE_LIBDLPI_H)
39  SET(SIGAR_LINK_FLAGS "-lkstat -ldl -lnsl -lsocket -lresolv -ldlpi")
40ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
41
42## solaris
43IF (CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
44  SET(SIGAR_SRC os/hpux/hpux_sigar.c)
45  INCLUDE_DIRECTORIES(os/hpux/)
46  ADD_DEFINITIONS(-DSIGAR_HPUX)
47  SET(SIGAR_LINK_FLAGS -lnm)
48ENDIF(CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
49
50## aix
51IF (CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
52  SET(SIGAR_SRC os/aix/aix_sigar.c)
53
54  INCLUDE_DIRECTORIES(os/aix/)
55  SET(SIGAR_LINK_FLAGS -lodm -lcfg)
56ENDIF(CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
57
58IF(WIN32)
59  ADD_DEFINITIONS(-DSIGAR_SHARED)
60  ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
61  SET(SIGAR_SRC os/win32/peb.c os/win32/win32_sigar.c os/win32/wmi.cpp)
62  INCLUDE_DIRECTORIES(os/win32)
63ENDIF(WIN32)
64
65SET(SIGAR_SRC ${SIGAR_SRC}
66  sigar.c
67  sigar_cache.c
68  sigar_fileinfo.c
69  sigar_format.c
70  sigar_ptql.c
71  sigar_signal.c
72  sigar_util.c
73)
74
75ADD_LIBRARY(sigar SHARED ${SIGAR_SRC})
76SET_TARGET_PROPERTIES(sigar PROPERTIES COMPILE_FLAGS -DBUILDING_SIGAR=1)
77
78IF(WIN32)
79	TARGET_LINK_LIBRARIES(sigar ws2_32 netapi32 version)
80ENDIF(WIN32)
81IF(SIGAR_LINK_FLAGS)
82  SET_TARGET_PROPERTIES(sigar PROPERTIES LINK_FLAGS "${SIGAR_LINK_FLAGS}")
83ENDIF(SIGAR_LINK_FLAGS)
84
85INSTALL(TARGETS sigar
86	RUNTIME DESTINATION bin
87	ARCHIVE DESTINATION lib
88	LIBRARY DESTINATION lib
89	)
90