forked from n0la/libirc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
92 lines (78 loc) · 2.07 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
PROJECT(IRC VERSION 0.2.1 LANGUAGES C)
ENABLE_TESTING()
FIND_PACKAGE(BISON REQUIRED)
FIND_PACKAGE(FLEX REQUIRED)
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(CMOCKA cmocka REQUIRED)
PKG_CHECK_MODULES(LIBTLS libtls)
PKG_CHECK_MODULES(GNUTLS gnutls)
SET(DEST_DIR "${CMAKE_INSTALL_PREFIX}")
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/libirc.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/libirc.pc"
@ONLY
)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/libirc.pc"
DESTINATION share/pkgconfig)
BISON_TARGET("config_parse"
"${CMAKE_CURRENT_SOURCE_DIR}/lib/config_parse.y"
"${CMAKE_CURRENT_BINARY_DIR}/config_parse.c"
)
FLEX_TARGET("config_lex"
"${CMAKE_CURRENT_SOURCE_DIR}/lib/config_lex.l"
"${CMAKE_CURRENT_BINARY_DIR}/config_lex.c"
)
SET(TARGET "irc")
SET(SOURCES
"lib/irc.c"
"lib/client.c"
"lib/message.c"
"lib/queue.c"
"lib/strbuf.c"
"lib/pa.c"
"lib/util.c"
"lib/config.c"
"lib/ssl.h"
"lib/tag.c"
"${CMAKE_CURRENT_BINARY_DIR}/config_parse.c"
"${CMAKE_CURRENT_BINARY_DIR}/config_lex.c"
)
SET(HEADERS
"irc/error.h"
"irc/irc.h"
"irc/client.h"
"irc/queue.h"
"irc/pa.h"
"irc/strbuf.h"
"irc/util.h"
"irc/config.h"
"irc/message.h"
"irc/tag.h"
)
IF (NOT LIBTLS_FOUND AND NOT GNUTLS_FOUND)
MESSAGE(FATAL_ERROR "No suitable TLS implementation found")
ENDIF()
IF (LIBTLS_FOUND)
LIST(APPEND SOURCES "lib/libtls.c")
INCLUDE_DIRECTORIES(${LIBTLS_INCLUDE_DIR})
ELSEIF (GNUTLS_FOUND)
LIST(APPEND SOURCES "lib/gnutls.c")
INCLUDE_DIRECTORIES(${GNUTLS_INCLUDE_DIR})
ENDIF()
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}")
ADD_LIBRARY(${TARGET} SHARED ${SOURCES} ${HEADERS})
SET_TARGET_PROPERTIES(${TARGET}
PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
INCLUDE(GNUInstallDirs)
INSTALL(TARGETS ${TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR})
INSTALL(FILES ${HEADERS} DESTINATION include/irc)
IF (LIBTLS_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${LIBTLS_LIBRARIES})
ELSEIF (GNUTLS_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${GNUTLS_LIBRARIES})
ENDIF()
ADD_SUBDIRECTORY(tests)