summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
blob: 2785fe977e6ddf6d7e3a10abb64bda2c9d56f334 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#
# Copyright (C) 2003-2010 Sebastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2007-2008 Julien Louis <ptitlouis@sysif.net>
# Copyright (C) 2008-2009 Emmanuel Bouthenot <kolter@openics.org>
#
# This file is part of WeeChat, the extensible chat client.
#
# WeeChat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# WeeChat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with WeeChat.  If not, see <http://www.gnu.org/licenses/>.
#

ADD_DEFINITIONS(-DHAVE_CONFIG_H)

INCLUDE(CheckIncludeFiles)
INCLUDE(CheckFunctionExists)

CHECK_INCLUDE_FILES("arpa/inet.h" HAVE_ARPA_INET_H)
CHECK_INCLUDE_FILES("limits.h" HAVE_LIMITS_H)
CHECK_INCLUDE_FILES("locale.h" HAVE_LOCALE_H)
CHECK_INCLUDE_FILES("netdb.h" HAVE_NETDB_H)
CHECK_INCLUDE_FILES("netinet/in.h" HAVE_NETINET_IN_H)
CHECK_INCLUDE_FILES("stdlib.h" HAVE_STDLIB_H)
CHECK_INCLUDE_FILES("string.h" HAVE_STRING_H)
CHECK_INCLUDE_FILES("sys/socket.h" HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILES("sys/time.h" HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES("sys/types.h" HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
CHECK_INCLUDE_FILES("pwd.h" HAVE_PWD_H)
CHECK_INCLUDE_FILES("errno.h" HAVE_ERRNO_H)
CHECK_INCLUDE_FILES("wchar.h" HAVE_WCHAR_H)
CHECK_INCLUDE_FILES("langinfo.h" HAVE_LANGINFO_CODESET)
IF(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
  CHECK_INCLUDE_FILES("utf8/wchar.h" HAVE_UTF8_WCHAR_H)
ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")

CHECK_FUNCTION_EXISTS(gethostbyname HAVE_GETHOSTBYNAME)
CHECK_FUNCTION_EXISTS(gethostname HAVE_GETHOSTNAME)
CHECK_FUNCTION_EXISTS(getsockname HAVE_GETSOCKNAME)
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
CHECK_FUNCTION_EXISTS(inet_ntoa HAVE_INET_NTOA)
CHECK_FUNCTION_EXISTS(memset HAVE_MEMSET)
CHECK_FUNCTION_EXISTS(mkdir HAVE_MKDIR)
CHECK_FUNCTION_EXISTS(select HAVE_SELECT)
CHECK_FUNCTION_EXISTS(setlocale HAVE_SETLOCALE)
CHECK_FUNCTION_EXISTS(socket HAVE_SOCKET)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(strchr HAVE_STRCHR)
CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP)
CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP)
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
CHECK_FUNCTION_EXISTS(strpbrk HAVE_STRPBRK)
CHECK_FUNCTION_EXISTS(strrchr HAVE_STRRCHR)
CHECK_FUNCTION_EXISTS(strstr HAVE_STRSTR)

CHECK_INCLUDE_FILES("regex.h" HAVE_REGEX_H)
CHECK_FUNCTION_EXISTS(regexec HAVE_REGEXEC)


#needs to be splitted in subdirectories
# FIXME: weechat_gui_common MUST be the first lib in the list
SET(STATIC_LIBS weechat_gui_common)

# Check for Large File Support
IF(ENABLE_LARGEFILE)
  ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
ENDIF(ENABLE_LARGEFILE)

# Check for Gettext
IF(ENABLE_NLS)
  FIND_PACKAGE(Gettext)
  IF(GETTEXT_FOUND)
    ADD_DEFINITIONS(-DENABLE_NLS)
  ENDIF(GETTEXT_FOUND)
ENDIF(ENABLE_NLS)

# Check for libgcrypt
IF(ENABLE_GCRYPT)
  FIND_PACKAGE(Gcrypt)
  IF(GCRYPT_FOUND)
    ADD_DEFINITIONS(-DHAVE_GCRYPT)
    LIST(APPEND EXTRA_LIBS "${GCRYPT_LDFLAGS}")
  ENDIF(GCRYPT_FOUND)
ENDIF(ENABLE_GCRYPT)

# Check for GnuTLS
IF(ENABLE_GNUTLS)
  FIND_PACKAGE(GnuTLS)
  
  IF(GNUTLS_FOUND)
    STRING(REGEX REPLACE "/[^/]*$" "" GNUTLS_LIBRARY_PATH "${GNUTLS_LIBRARY}")
    ADD_DEFINITIONS(-DHAVE_GNUTLS)
    INCLUDE_DIRECTORIES(${GNUTLS_INCLUDE_PATH})
    SET(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -L${GNUTLS_LIBRARY_PATH}")
    LIST(APPEND EXTRA_LIBS gnutls)
  ENDIF(GNUTLS_FOUND)
ENDIF(ENABLE_GNUTLS)

# Check for iconv
FIND_PACKAGE(Iconv)
IF(ICONV_FOUND)
  ADD_DEFINITIONS( -DHAVE_ICONV )
ENDIF(ICONV_FOUND)

FIND_LIBRARY(DL_LIBRARY
  NAMES dl
  PATHS /lib /usr/lib /usr/libexec /usr/local/lib /usr/local/libexec
)
LIST(APPEND STATIC_LIBS weechat_plugins)
IF(DL_LIBRARY)
  STRING(REGEX REPLACE "/[^/]*$" "" DL_LIBRARY_PATH "${DL_LIBRARY}")
  SET(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -L${DL_LIBRARY_PATH}")
  LIST(APPEND EXTRA_LIBS dl)
ENDIF(DL_LIBRARY)

IF(COMMAND cmake_policy)
  cmake_policy(SET CMP0005 NEW)
  ADD_DEFINITIONS(-DWEECHAT_VERSION="${VERSION}" -DWEECHAT_LICENSE="${LICENSE}")
ELSE(COMMAND cmake_policy)
  ADD_DEFINITIONS(-DWEECHAT_VERSION='"${VERSION}"' -DWEECHAT_LICENSE='"${LICENSE}"')
ENDIF(COMMAND cmake_policy)

ADD_SUBDIRECTORY( core )
LIST(APPEND STATIC_LIBS weechat_core)

ADD_SUBDIRECTORY( plugins )

ADD_SUBDIRECTORY( gui )