-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
224 lines (185 loc) · 6.45 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
cmake_minimum_required(VERSION 2.8.6)
project(Jreen)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include( GNUInstallDirs )
set(CMAKE_JREEN_VERSION_MAJOR 1 CACHE INT "Major Jreen version number" FORCE)
set(CMAKE_JREEN_VERSION_MINOR 3 CACHE INT "Minor Jreen version number" FORCE)
set(CMAKE_JREEN_VERSION_PATCH 0 CACHE INT "Release Jreen version number" FORCE)
set(CMAKE_JREEN_VERSION_STRING "${CMAKE_JREEN_VERSION_MAJOR}.${CMAKE_JREEN_VERSION_MINOR}.${CMAKE_JREEN_VERSION_PATCH}" CACHE STRING "Jreen version string" FORCE)
# Search for source and headers in source directory (non-recursive)
file(GLOB_RECURSE SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
option(JREEN_FORCE_QT4 "Force using of Qt4 in Jreen" off)
set(JREEN_SUFFIX "")
set(JREEN_INCLUDE_PATH "")
set(JREEN_QT_MIDDLE "")
if(NOT JREEN_FORCE_QT4)
find_package(Qt5Core QUIET)
endif()
if(Qt5Core_DIR)
find_package(Qt5Network QUIET)
message(STATUS "Found Qt5!")
set(JREEN_SUFFIX "-qt5")
set(JREEN_INCLUDE_PATH "jreen-qt5")
set(JREEN_QT_MIDDLE "5")
add_definitions("-DQT_DISABLE_DEPRECATED_BEFORE=0")
list(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/sjdns.cpp")
else()
message(STATUS "Could not find Qt5, so let's use Qt4...")
set(JREEN_INCLUDE_PATH "jreen-qt4")
find_package(Qt4 4.6.0 COMPONENTS QtCore QtNetwork REQUIRED)
macro(qt5_use_modules)
endmacro()
include(${QT_USE_FILE})
endif()
if(JREEN_BUILD_INTERNAL)
add_definitions("-DJ_BUILD_INTERNAL")
endif()
find_package(PkgConfig)
find_package(GSASL REQUIRED)
pkg_search_module(SPEEX speex)
if(NOT SPEEX_FOUND)
message(STATUS "Could not find speex library.")
else()
message(STATUS "Speex library is found.")
include_directories(${SPEEX_INCLUDE_DIRS})
add_definitions("-DJREEN_HAVE_SPEEX=1")
endif()
# FindZLIB is broken on Ubuntu, so find the library using pkg-config
if(LINUX)
find_package(PkgConfig)
pkg_search_module(ZLIB_PKGCONF REQUIRED zlib)
find_path(ZLIB_INCLUDE_DIR
NAMES zlib.h
PATHS ${ZLIB_PKGCONF_INCLUDE_DIRS}
)
find_library(ZLIB_LIBRARIES
NAMES z
PATHS ${ZLIB_PKGCONF_LIBRARY_DIRS}
)
if(NOT ZLIB_INCLUDE_DIR)
message(SEND_ERROR "Could not find zlib includes.")
endif(NOT ZLIB_INCLUDE_DIR)
if(NOT ZLIB_LIBRARIES)
message(SEND_ERROR "Could not find zlib library.")
endif(NOT ZLIB_LIBRARIES)
else()
find_package(ZLIB REQUIRED)
endif()
# Add include directories
include_directories(.
${CMAKE_CURRENT_BINARY_DIR}
3rdparty
${GSASL_INCLUDE_DIRS}
${GSASL_INCLUDEDIR}
${ZLIB_INCLUDE_DIR}
)
LIST(APPEND SRC ${3RD_PARTY_SRC_C})
LIST(APPEND SRC ${3RD_PARTY_SRC})
# Ice support
option(JREEN_USE_IRISICE "Use ICE from IRIS" OFF)
if (JREEN_USE_IRISICE)
file(GLOB_RECURSE ICESUPPORT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/icesupport/*.cpp")
file(GLOB_RECURSE ICESUPPORT_SRC_C "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/icesupport/*.c")
list(APPEND SRC ${ICESUPPORT_SRC})
list(APPEND SRC ${ICESUPPORT_SRC_C})
add_definitions("-DHAVE_IRISICE")
endif()
if(NOT Qt5Core_DIR)
option(JREEN_USE_SYSTEM_JDNS "Use system JDNS" OFF)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns")
set(JREEN_USE_SYSTEM_JDNS ON)
endif()
if(JREEN_USE_SYSTEM_JDNS)
# For Linux it was found already before at line 29
if(NOT LINUX)
find_package(PkgConfig)
endif()
pkg_search_module(JDNS REQUIRED qjdns)
include_directories(${JDNS_INCLUDE_DIR})
list(APPEND EXTRA_LIBS ${JDNS_LIBRARIES})
else()
file(GLOB_RECURSE JDNS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns/*.cpp")
file(GLOB_RECURSE JDNS_SRC_C "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns/*.c")
list(APPEND SRC ${JDNS_SRC})
list(APPEND SRC ${JDNS_SRC_C})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty")
endif()
endif()
# This project will generate library
if(SYMBIAN)
set(JREEN_BUILD_TYPE STATIC)
else()
set(JREEN_BUILD_TYPE SHARED)
endif()
ADD_LIBRARY(jreen${JREEN_SUFFIX} ${JREEN_BUILD_TYPE} ${SRC} ${MOC_SRC})
#compiler flags
#fixme add macro to clang
if(CMAKE_COMPILER_IS_GNUCXX)
if(SYMBIAN)
#disable stupid warnings
ADD_DEFINITIONS("-w")
else()
ADD_DEFINITIONS("-Wall -Wextra" ) #add -Werror
ENDif()
if(NOT WIN32)
ADD_DEFINITIONS("-fvisibility=hidden" )
endif(NOT WIN32)
elseif(MSVC)
ADD_DEFINITIONS("/W3" )
endif()
set_target_properties(jreen${JREEN_SUFFIX} PROPERTIES
VERSION ${CMAKE_JREEN_VERSION_STRING}
SOVERSION ${CMAKE_JREEN_VERSION_MAJOR}
DEFINE_SYMBOL J_BUILD_LIBRARY
)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/jreen" )
file(GLOB_RECURSE JREEN_INCLUDE_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
foreach(header ${JREEN_INCLUDE_HEADERS})
if(NOT ${header} MATCHES ".*_p\\.h")
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/include/jreen/${header}")
file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/jreen/${header}"
"#include \"${CMAKE_CURRENT_SOURCE_DIR}/src/${header}\"
"
)
endif(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/include/jreen/${header}")
get_filename_component(headerPath ${header} PATH)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/${header}"
DESTINATION include/${JREEN_INCLUDE_PATH}/jreen/${headerPath}
COMPONENT jreenDevel
)
endif(NOT ${header} MATCHES ".*_p\\.h")
endforeach(header)
set(JREEN_LIBRARIES jreen${JREEN_SUFFIX} CACHE INTERNAL "" )
set(JREEN_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/include" CACHE INTERNAL "")
if(WIN32)
list(APPEND EXTRA_LIBS ws2_32)
endif()
if(SPEEX_FOUND)
list(APPEND EXTRA_LIBS ${SPEEX_LIBRARIES} )
endif()
target_link_libraries(jreen${JREEN_SUFFIX}
${QT_LIBRARIES}
${GSASL_LIBRARIES}
${ZLIB_LIBRARIES}
${EXTRA_LIBS}
)
set_target_properties(jreen${JREEN_SUFFIX} PROPERTIES AUTOMOC TRUE)
qt5_use_modules(jreen${JREEN_SUFFIX} Core Network)
# Install package config file
if(NOT WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libjreen.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libjreen${JREEN_SUFFIX}.pc
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjreen${JREEN_SUFFIX}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()
install( TARGETS jreen${JREEN_SUFFIX}
RUNTIME DESTINATION bin
COMPONENT jreen
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT jreen
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT jreenDevel
BUNDLE DESTINATION library
)