xref: /6.6.0/sigar/src/CMakeLists.txt (revision 7038e53c)
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    ADD_DEFINITIONS(-DDARWIN_HAS_LIBPROC_H=1)
21    SET(SIGAR_LINK_FLAGS "-framework CoreServices -framework IOKit")
22  ELSE(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
23    ## freebsd needs libkvm
24    SET(SIGAR_LINK_FLAGS "-lkvm")
25  ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
26ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
27
28## solaris
29IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
30  SET(SIGAR_SRC
31	os/solaris/solaris_sigar.c
32	os/solaris/get_mib2.c
33	os/solaris/kstats.c
34	os/solaris/procfs.c
35  )
36
37  INCLUDE_DIRECTORIES(os/solaris/)
38  ADD_DEFINITIONS(-DSOLARIS)
39  ADD_DEFINITIONS(-DHAVE_LIBDLPI_H)
40  SET(SIGAR_LINK_FLAGS "-lkstat -ldl -lnsl -lsocket -lresolv -ldlpi")
41ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
42
43## solaris
44IF (CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
45  SET(SIGAR_SRC os/hpux/hpux_sigar.c)
46  INCLUDE_DIRECTORIES(os/hpux/)
47  ADD_DEFINITIONS(-DSIGAR_HPUX)
48  SET(SIGAR_LINK_FLAGS -lnm)
49ENDIF(CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
50
51## aix
52IF (CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
53  SET(SIGAR_SRC os/aix/aix_sigar.c)
54
55  INCLUDE_DIRECTORIES(os/aix/)
56  SET(SIGAR_LINK_FLAGS -lodm -lcfg)
57ENDIF(CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
58
59IF(WIN32)
60  ADD_DEFINITIONS(-DSIGAR_SHARED)
61  ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
62  SET(SIGAR_SRC os/win32/peb.c os/win32/win32_sigar.c os/win32/wmi.cpp)
63  INCLUDE_DIRECTORIES(os/win32)
64ENDIF(WIN32)
65
66SET(SIGAR_SRC ${SIGAR_SRC}
67  sigar.c
68  sigar_cache.c
69  sigar_fileinfo.c
70  sigar_format.c
71  sigar_util.c
72)
73
74ADD_LIBRARY(sigar SHARED ${SIGAR_SRC})
75SET_TARGET_PROPERTIES(sigar PROPERTIES COMPILE_FLAGS -DBUILDING_SIGAR=1)
76
77IF(WIN32)
78	TARGET_LINK_LIBRARIES(sigar ws2_32 netapi32 version)
79ENDIF(WIN32)
80IF(SIGAR_LINK_FLAGS)
81  SET_TARGET_PROPERTIES(sigar PROPERTIES LINK_FLAGS "${SIGAR_LINK_FLAGS}")
82ENDIF(SIGAR_LINK_FLAGS)
83
84INSTALL(TARGETS sigar
85	RUNTIME DESTINATION bin
86	ARCHIVE DESTINATION lib
87	LIBRARY DESTINATION lib
88	)
89