xref: /6.6.0/sigar/src/CMakeLists.txt (revision 73353fe6)
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/)
10
11  # Fedora 28+ has removed Sun RPC interface from glibc
12  # https://fedoraproject.org/wiki/Changes/SunRPCRemoval
13  CHECK_INCLUDE_FILES(rpc/rpc.h HAVE_RPC_RPC_H)
14  IF(NOT HAVE_RPC_RPC_H)
15    INCLUDE(FindPkgConfig)
16    PKG_SEARCH_MODULE(TIRPC libtirpc)
17    IF(TIRPC_FOUND)
18      SET(SIGAR_LINK_FLAGS ${TIRPC_LDFLAGS})
19      INCLUDE_DIRECTORIES(${TIRPC_INCLUDE_DIRS})
20    ENDIF(TIRPC_FOUND)
21  ENDIF(NOT HAVE_RPC_RPC_H)
22
23ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
24
25## macosx, freebsd
26IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
27  SET(SIGAR_SRC os/darwin/darwin_sigar.c)
28
29  INCLUDE_DIRECTORIES(os/darwin/)
30  IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
31    INCLUDE_DIRECTORIES(/Developer/Headers/FlatCarbon/)
32    ADD_DEFINITIONS(-DDARWIN)
33    ADD_DEFINITIONS(-DDARWIN_HAS_LIBPROC_H=1)
34    SET(SIGAR_LINK_FLAGS "-framework CoreServices -framework IOKit")
35  ELSE(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
36    ## freebsd needs libkvm
37    SET(SIGAR_LINK_FLAGS "-lkvm")
38  ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
39ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
40
41## solaris
42IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
43  SET(SIGAR_SRC
44	os/solaris/solaris_sigar.c
45	os/solaris/get_mib2.c
46	os/solaris/kstats.c
47	os/solaris/procfs.c
48  )
49
50  INCLUDE_DIRECTORIES(os/solaris/)
51  ADD_DEFINITIONS(-DSOLARIS)
52  ADD_DEFINITIONS(-DHAVE_LIBDLPI_H)
53  SET(SIGAR_LINK_FLAGS "-lkstat -ldl -lnsl -lsocket -lresolv -ldlpi")
54ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
55
56## solaris
57IF (CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
58  SET(SIGAR_SRC os/hpux/hpux_sigar.c)
59  INCLUDE_DIRECTORIES(os/hpux/)
60  ADD_DEFINITIONS(-DSIGAR_HPUX)
61  SET(SIGAR_LINK_FLAGS -lnm)
62ENDIF(CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
63
64## aix
65IF (CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
66  SET(SIGAR_SRC os/aix/aix_sigar.c)
67
68  INCLUDE_DIRECTORIES(os/aix/)
69  SET(SIGAR_LINK_FLAGS -lodm -lcfg)
70ENDIF(CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
71
72IF(WIN32)
73  ADD_DEFINITIONS(-DSIGAR_SHARED)
74  ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
75  SET(SIGAR_SRC os/win32/peb.c os/win32/win32_sigar.c os/win32/wmi.cpp)
76  INCLUDE_DIRECTORIES(os/win32)
77ENDIF(WIN32)
78
79SET(SIGAR_SRC ${SIGAR_SRC}
80  sigar.c
81  sigar_cache.c
82  sigar_fileinfo.c
83  sigar_format.c
84  sigar_util.c
85)
86
87ADD_LIBRARY(sigar SHARED ${SIGAR_SRC})
88SET_TARGET_PROPERTIES(sigar PROPERTIES COMPILE_FLAGS -DBUILDING_SIGAR=1)
89
90IF(WIN32)
91	TARGET_LINK_LIBRARIES(sigar ws2_32 netapi32 version)
92ENDIF(WIN32)
93IF(SIGAR_LINK_FLAGS)
94  SET_TARGET_PROPERTIES(sigar PROPERTIES LINK_FLAGS "${SIGAR_LINK_FLAGS}")
95ENDIF(SIGAR_LINK_FLAGS)
96
97INSTALL(TARGETS sigar
98	RUNTIME DESTINATION bin
99	ARCHIVE DESTINATION lib
100	LIBRARY DESTINATION lib
101	)
102