Coding style
[gammu.git] / CMakeLists.txt
bloba64d7c9ec90153d9f3f64eb5968996f9608c6e4b
1 # cmake <http://www.cmake.org> build file for Gammu
2 # Copyright (c) 2007 - 2010 Michal Cihar
3 # vim: expandtab sw=4 ts=4 sts=4:
5 # I didn't check older versions
6 # However 2.6 is needed for crosscompiling, Cpack components and other useful things
7 cmake_minimum_required (VERSION 2.4.2)
8 INCLUDE (CMakeForceCompiler)
9 if (ENABLE_TIGER)
10     # In order to build for tiger we need to force to gcc-4.0
11     CMAKE_FORCE_C_COMPILER   (gcc-4.0 i686-apple-darwin10-gcc-4.0.1)
12 endif(ENABLE_TIGER)
14 project (Gammu C)
16 # Where to lookup modules
17 set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
19 # Silent some warnings from CMake 2.6
20 if(COMMAND cmake_policy)
21     cmake_policy(SET CMP0003 NEW)
22 endif(COMMAND cmake_policy)
24 if (NOT CLANG_COMPILER)
25     option (COVERAGE "Add flags for Coverage analysis" OFF)
26 endif (NOT CLANG_COMPILER)
28 option (ONLINE_TESTING "Enable testing of parts which use remote servers" OFF)
29 option (PSQL_TESTING "Enable testing of PostgreSQL SMSD backend" OFF)
30 option (MYSQL_TESTING "Enable testing of MySQL SMSD backend" OFF)
31 option (ODBC_TESTING "Enable testing of ODBC MySQL SMSD backend" OFF)
32 option (BUILD_SHARED_LIBS "Build shared libraries" ON)
34 option (LARGE_FILES "Support for large files" ON)
35 if (LARGE_FILES)
36     add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
37 endif (LARGE_FILES)
39 if (CMAKE_CROSSCOMPILING AND MINGW)
40     set (GAMMU_TEST_SUFFIX ".exe")
41 else (CMAKE_CROSSCOMPILING AND MINGW)
42     set (GAMMU_TEST_SUFFIX "")
43 endif (CMAKE_CROSSCOMPILING AND MINGW)
45 # Set version
46 set (GAMMU_VERSION "1.30.92" CACHE INTERNAL "")
47 string (REGEX REPLACE "^([0-9]*)\\.([0-9]*)\\.([0-9]*)$" "\\1" "GAMMU_VERSION_MAJOR" "${GAMMU_VERSION}")
48 string (REGEX REPLACE "^([0-9]*)\\.([0-9]*)\\.([0-9]*)$" "\\2" "GAMMU_VERSION_MINOR" "${GAMMU_VERSION}")
49 string (REGEX REPLACE "^([0-9]*)\\.([0-9]*)\\.([0-9]*)$" "\\3" "GAMMU_VERSION_PATCH" "${GAMMU_VERSION}")
50 math(EXPR GAMMU_VERSION_NUM "${GAMMU_VERSION_MAJOR} * 10000 + ${GAMMU_VERSION_MINOR} * 100 + ${GAMMU_VERSION_PATCH}")
51 message (STATUS "Configuring ${CMAKE_PROJECT_NAME} ${GAMMU_VERSION}")
53 set (GAMMU_SOVERSION "7" CACHE INTERNAL "")
55 if ("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
56     message ("Warning: In tree build is not recommended way to build Gammu.")
57 endif ("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
59 # For debugging
60 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
61 #    set (CMAKE_VERBOSE_MAKEFILE ON)
62     set (DEBUG 1)
63 else (CMAKE_BUILD_TYPE STREQUAL "Debug")
64     set (DEBUG 0)
65 endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
67 # Standard packages
68 include (CheckCSourceCompiles)
69 include (CheckCCompilerFlag)
70 include (CheckIncludeFile)
71 include (CheckIncludeFiles)
72 include (CheckFunctionExists)
73 include (CheckSymbolExists)
74 include (CheckTypeSize)
75 include (CheckLibraryExists)
76 include (FindPkgConfig)
78 # Packages in our sources (mostly taken from KDE)
79 include (MacroOptionalFindPackage)
80 include (MacroAddDLL)
81 include (MacroGammuOption)
82 include (MacroTuneCompiler)
84 # WE use pkgconfig later
85 find_package (PkgConfig)
87 # Standard packages
88 macro_optional_find_package (Doxygen)
90 # I'd say this is task of CMake to export this
91 check_symbol_exists (__clang__ "" CLANG_COMPILER)
92 if (APPLE)
93     if (ENABLE_TIGER)
94         # if we do for 10.4
95         MACRO_TUNE_COMPILER("-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
96         MACRO_TUNE_COMPILER("-arch i386")
97     else (ENABLE_TIGER)
98         # else try to be compatible with 10.5
99         MACRO_TUNE_COMPILER("-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk")
100         MACRO_TUNE_COMPILER("-arch x86_64")
101     endif (ENABLE_TIGER)
102 endif (APPLE)
104 # Configuration checks
105 check_symbol_exists (strncasecmp "string.h" HAVE_STRNCASECMP)
106 check_symbol_exists (strcasecmp "string.h" HAVE_STRCASECMP)
107 check_symbol_exists (_strnicmp "string.h" HAVE_STRNICMP)
108 check_symbol_exists (_stricmp "string.h" HAVE_STRICMP)
109 check_function_exists (strcasestr HAVE_STRCASESTR)
110 check_function_exists (strchrnul HAVE_STRCHRNUL)
111 check_function_exists (strtoull HAVE_STRTOULL)
112 check_include_file (dirent.h HAVE_DIRENT_H)
113 check_include_file (sys/ioctl.h HAVE_SYS_IOCTL_H)
114 check_include_file (sys/utsname.h HAVE_SYS_UTSNAME_H)
115 check_include_file (unistd.h HAVE_UNISTD_H)
117 check_include_file (wchar.h HAVE_WCHAR_H)
118 if (HAVE_WCHAR_H)
119     check_include_files ("wchar.h;wctype.h" HAVE_WCTYPE_H)
120     check_symbol_exists (iswspace "wchar.h;wctype.h" HAVE_ISWSPACE)
121     check_symbol_exists (towlower "wchar.h;wctype.h" HAVE_TOWLOWER)
122 else (HAVE_WCHAR_H)
123     check_include_file (wctype.h HAVE_WCTYPE_H)
124     check_symbol_exists (iswspace "wctype.h" HAVE_ISWSPACE)
125     check_symbol_exists (towlower "wctype.h" HAVE_TOWLOWER)
126 endif (HAVE_WCHAR_H)
127 check_symbol_exists (I_SETSIG "stropts.h" HAVE_I_SETSIG)
128 check_include_file (strings.h HAVE_STRINGS_H)
129 # These checks are required for check_type_size() on cmake < 2.6.0
130 check_include_file (sys/types.h HAVE_SYS_TYPES_H)
131 check_include_file (stdint.h HAVE_STDINT_H)
132 check_include_file (stddef.h HAVE_STDDEF_H)
133 check_function_exists (scandir HAVE_SCANDIR)
134 check_function_exists (alphasort HAVE_ALPHASORT)
135 check_symbol_exists (getopt "unistd.h" HAVE_GETOPT)
136 check_symbol_exists (getopt_long "getopt.h" HAVE_GETOPT_LONG)
137 check_symbol_exists (daemon "unistd.h" HAVE_DAEMON_UNISTD)
138 check_symbol_exists (daemon "stdlib.h" HAVE_DAEMON_STDLIB)
139 check_symbol_exists (kill "signal.h" HAVE_KILL)
140 check_symbol_exists (getpwnam "pwd.h" HAVE_GETPWNAM)
141 check_symbol_exists (getgrnam "grp.h" HAVE_GETGRNAM)
142 check_symbol_exists (getpwuid "pwd.h" HAVE_GETPWUID)
143 check_symbol_exists (getuid "unistd.h" HAVE_GETUID)
144 check_symbol_exists (initgroups "grp.h" HAVE_INITGROUPS)
145 check_symbol_exists (setuid "unistd.h" HAVE_SETUID)
146 check_symbol_exists (setgid "unistd.h" HAVE_SETGID)
147 check_symbol_exists (SIGHUP "signal.h" HAVE_SIGHUP)
148 check_symbol_exists (dup "unistd.h" HAVE_DUP_UNISTD_H)
149 check_symbol_exists (getpid "unistd.h" HAVE_GETPID)
150 check_symbol_exists (getpass "unistd.h" HAVE_GETPASS)
151 check_symbol_exists (alarm "unistd.h" HAVE_ALARM)
152 check_symbol_exists (dup "io.h" HAVE_DUP_IO_H)
153 check_symbol_exists (shmget "sys/shm.h" HAVE_SHM)
154 check_c_source_compiles ("
155 #define _XOPEN_SOURCE
156 #define _BSD_SOURCE
157 #include <time.h>
159 int main(void) {
160     struct tm timestruct;
161     strptime(\"11:22\", \"%H:%M\", &timestruct);
162     return 0;
163 }" HAVE_STRPTIME)
164 check_c_source_compiles ("
165 #include <stdio.h>
166 #include <syslog.h>
167 #include <stdarg.h>
169 int main(void) {
170     syslog(LOG_NOTICE, \"aaa %d\", 1);
171     return 0;
173 "  HAVE_SYSLOG)
174 # Some compilers (eg. BCC) have this in ctype.h
175 if (NOT HAVE_TOWLOWER)
176     check_symbol_exists (towlower "ctype.h" HAVE_TOWLOWER_CTYPE)
177     if (HAVE_TOWLOWER_CTYPE)
178         set (HAVE_TOWLOWER ${HAVE_TOWLOWER_CTYPE} CACHE INTERNAL "")
179     endif (HAVE_TOWLOWER_CTYPE)
180 endif (NOT HAVE_TOWLOWER)
182 # Standard packages
183 macro_optional_find_package (Threads)
185 # Used (optionally for testing)
186 find_program(SH_BIN sh)
187 find_program(BASH_BIN bash)
188 find_program(SQLITE_BIN sqlite3)
189 find_program(SED_BIN sed)
190 find_program(MYSQL_BIN mysql)
191 find_program(PSQL_BIN psql)
193 # Check for Python
194 set (BUILD_PYTHON "" CACHE FILEPATH "Path to python interpreter")
196 if (BUILD_PYTHON)
197     set (WITH_PYTHON TRUE CACHE BOOL "Build Python bindings")
198     set (PYTHON_EXECUTABLE ${BUILD_PYTHON})
199     execute_process(
200         COMMAND
201             ${PYTHON_EXECUTABLE} -c "import sys; print('.'.join([str(x) for x in sys.version_info[:2]]))"
202         OUTPUT_VARIABLE PYTHON_VERSION
203         OUTPUT_STRIP_TRAILING_WHITESPACE
204         )
205     if("${PYTHON_VERSION}" STREQUAL "")
206         message(FATAL_ERROR "Failed to execute defined Python: ${BUILD_PYTHON}")
207     endif("${PYTHON_VERSION}" STREQUAL "")
209     message (STATUS "Compiling for Python ${PYTHON_VERSION}")
210     execute_process(
211         COMMAND
212             ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())"
213         OUTPUT_VARIABLE PYTHON_INCLUDE_PATH
214         OUTPUT_STRIP_TRAILING_WHITESPACE
215         )
217     string (REPLACE "." "" PYTHON_VERSION_NO_DOTS "${PYTHON_VERSION}")
218     find_library (PYTHON_LIBRARY
219         NAMES python${PYTHON_VERSION_NO_DOTS} python${PYTHON_VERSION}
220         PATHS
221           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION}\\InstallPath]/libs
222         PATH_SUFFIXES
223           python${PYTHON_VERSION}/config
224         # Avoid finding the .dll in the PATH.  We want the .lib.
225         NO_SYSTEM_ENVIRONMENT_PATH
226       )
227 else (BUILD_PYTHON)
228     find_package(PythonInterp)
229     find_package(PythonLibs)
231     if (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
232         set (WITH_PYTHON TRUE CACHE BOOL "Build Python bindings")
233     else (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
234         set (WITH_PYTHON FALSE CACHE BOOL "Build Python bindings" FORCE)
235     endif (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
236 endif (BUILD_PYTHON)
238 if (PYTHON_EXECUTABLE)
239     execute_process(
240         COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print(sys.version_info[0])"
241         OUTPUT_VARIABLE PYTHON_MAJOR_VERSION
242         OUTPUT_STRIP_TRAILING_WHITESPACE
243         )
244     if ("${PYTHON_MAJOR_VERSION}" GREATER 2)
245         message("Python 3.x is not currently supported!")
246         set (WITH_PYTHON FALSE CACHE BOOL "Build Python bindings" FORCE)
247     endif ("${PYTHON_MAJOR_VERSION}" GREATER 2)
248 endif (PYTHON_EXECUTABLE)
250 # Packages in sources
251 macro_optional_find_package (MySQL)
252 macro_optional_find_package (ODBC)
253 macro_optional_find_package (Postgres)
254 macro_optional_find_package (LibDBI)
255 macro_optional_find_package (Libintl)
256 macro_optional_find_package (Iconv)
257 macro_optional_find_package (CURL)
258 macro_optional_find_package (Glib)
259 macro_optional_find_package (Gobject)
261 # Gudev stuff
262 pkg_check_modules(GUDEV gudev-1.0)
264 if (CMAKE_CROSSCOMPILING AND MINGW)
265     set (HAVE_WINT_T 4 CACHE INTERNAL "")
266     set (HAVE_WCHAR_T 4 CACHE INTERNAL "")
267 else (CMAKE_CROSSCOMPILING AND MINGW)
268     # Search for needed includes and functions
269     if (HAVE_WCHAR_H)
270         set (CMAKE_EXTRA_INCLUDE_FILES wchar.h)
271         check_type_size (wchar_t HAVE_WCHAR_T)
272         check_type_size (wint_t  HAVE_WINT_T)
273     endif (HAVE_WCHAR_H)
274     set (CMAKE_EXTRA_INCLUDE_FILES)
275 endif (CMAKE_CROSSCOMPILING AND MINGW)
277 set (CMAKE_EXTRA_INCLUDE_FILES stdio.h)
278 check_type_size (ssize_t HAVE_SSIZE_T)
279 set (CMAKE_EXTRA_INCLUDE_FILES)
280 if (HAVE_UNISTD_H)
281     set (CMAKE_EXTRA_INCLUDE_FILES unistd.h)
282     check_type_size(intptr_t HAVE_INTPTR_T)
283     set (CMAKE_EXTRA_INCLUDE_FILES)
284 else(HAVE_UNISTD_H)
285     check_type_size(intptr_t HAVE_INTPTR_T)
286 endif (HAVE_UNISTD_H)
288 check_c_source_compiles ("
289 #include <stdio.h>
291 int main(void) {
292     printf( __FUNCTION__);
293     return 0;
295 "  HAVE_MACRO_FUNCTION)
297 check_c_source_compiles ("
298 #include <time.h>
300 int main(void) {
301     struct tm tm;
302     tm.tm_zone;
303     return 0;
305 "  HAVE_STRUCT_TM_TM_ZONE)
307 check_c_source_compiles ("
308 #include <time.h>
310 int main(void) {
311     struct tm tm;
312         tm.tm_isdst     = daylight;
313     return 0;
315 "  HAVE_DAYLIGHT)
317 check_c_source_compiles ("
318 #include <stdio.h>
320 int main(void) {
321     printf( __FUNC__);
322     return 0;
324 "  HAVE_MACRO_FUNC)
327 OPTION(WITH_BLUETOOTH "Bluetooth support" ON)
328 if (WITH_BLUETOOTH)
329     if (WIN32 AND NOT CYGWIN)
330         # FIXME: This is currently hardcoded here, maybe there is test?
331         set(BLUETOOTH_FOUND ON)
332         message(STATUS "Using Windows native Bluetooth")
333         set(BLUETOOTH_SEARCH TRUE)
334     elseif(CYGWIN)
335         message(STATUS "Bluetooth is currently not supported in Cygwin")
336         message(STATUS "If you need it, contact us")
337     else (WIN32 AND NOT CYGWIN)
338         find_package (Bluez)
339         if (BLUEZ_FOUND)
340             set(BLUETOOTH_FOUND ON)
341             set(BLUETOOTH_SEARCH TRUE)
342             message(STATUS "Using BlueZ stack")
343         endif (BLUEZ_FOUND)
344         find_package (BSDBluetooth)
345         if (BSD_BLUE_FOUND)
346             set(BLUETOOTH_FOUND ON)
347             message(STATUS "Using BSD Bluetooth stack")
348             check_library_exists(bluetooth sdp_service_search_attribute "" HAVE_SDP_SERVICE_SEARCH_ATTRIBUTE)
349             check_library_exists(bluetooth bt_devinquiry "" HAVE_BT_DEVINQUIRY)
350             if (HAVE_SDP_SERVICE_SEARCH_ATTRIBUTE AND HAVE_BT_DEVINQUIRY)
351                 set(BLUETOOTH_SEARCH TRUE)
352             endif (HAVE_SDP_SERVICE_SEARCH_ATTRIBUTE AND HAVE_BT_DEVINQUIRY)
353         endif (BSD_BLUE_FOUND)
354         find_package (OSXBluetooth)
355         if (OSX_BLUE_FOUND)
356             set(BLUETOOTH_FOUND ON)
357             set(BLUETOOTH_SEARCH FALSE)
358             message(STATUS "Using OSX Bluetooth stack")
359         endif (OSX_BLUE_FOUND)
360     endif (WIN32 AND NOT CYGWIN)
361 else (WITH_BLUETOOTH)
362     set(BLUETOOTH_FOUND FALSE)
363     set(BLUETOOTH_INCLUDE_DIR)
364     set(BLUETOOTH_INCLUDES)
365     set(BLUETOOTH_LIBRARY)
366     set(BLUETOOTH_LIBRARIES)
367 endif (WITH_BLUETOOTH)
369 if (BLUETOOTH_FOUND)
370     message(STATUS "Bluetooth support enabled")
371 else (BLUETOOTH_FOUND)
372     if (WITH_BLUETOOTH AND NOT CYGWIN)
373         message("Bluetooth support disabled, please install libbluetooth-dev or equivalent to enable Bluetooth.")
374     endif (WITH_BLUETOOTH AND NOT CYGWIN)
375 endif (BLUETOOTH_FOUND)
377 macro_gammu_option (BLUETOOTH_RF_SEARCHING "Searching for RF channels with Bluetooth stack" ON BLUETOOTH_FOUND BLUETOOTH_SEARCH)
378 if (WITH_BLUETOOTH_RF_SEARCHING)
379     set (BLUETOOTH_RF_SEARCHING ON)
380 endif (WITH_BLUETOOTH_RF_SEARCHING)
382 OPTION(WITH_USB "Native USB support" ON)
383 if (WITH_USB)
384     find_package (LibUSB)
385 endif (WITH_USB)
387 OPTION(WITH_IRDA "IrDA support" ON)
388 if (WITH_IRDA)
389     if (WIN32 AND NOT CYGWIN)
390         # FIXME: This is currently hardcoded here, maybe there is test?
391         set (IRDA_FOUND TRUE)
392         message(STATUS "Using Windows native IrDA")
393     elseif(CYGWIN)
394         message(STATUS "IrDA is currently not supported in Cygwin")
395         message(STATUS "If you need it, contact us")
396         set (IRDA_FOUND FALSE)
397     else (WIN32 AND NOT CYGWIN)
398         check_c_source_compiles (
399             "
400 #include <sys/socket.h>
401 #include <linux/types.h>
402 #include <sys/ioctl.h>
403 #include <linux/irda.h>
404     int main(int argc, char **argv) {
405         return 0;
406     }
407             "
408             IRDA_FOUND
409             )
410         if (IRDA_FOUND)
411             message(STATUS "Using Linux native IrDA")
412         endif (IRDA_FOUND)
413     endif (WIN32 AND NOT CYGWIN)
414 else (WITH_IRDA)
415     set (IRDA_FOUND FALSE)
416 endif (WITH_IRDA)
418 if (IRDA_FOUND)
419     message(STATUS "IrDA support enabled")
420 endif (IRDA_FOUND)
422 if (MYSQL_FOUND)
423     set (HAVE_MYSQL_MYSQL_H TRUE)
424 endif (MYSQL_FOUND)
426 if (POSTGRES_FOUND)
427     set (HAVE_POSTGRESQL_LIBPQ_FE_H TRUE)
428 endif (POSTGRES_FOUND)
430 set (GAMMU_LIBS "")
432 if (BLUEZ_FOUND)
433     if (NOT "${BLUEZ_LIBRARIES}" STREQUAL "")
434         set (GAMMU_LIBS "${GAMMU_LIBS} -l${BLUEZ_LIBRARIES}")
435     endif (NOT "${BLUEZ_LIBRARIES}" STREQUAL "")
436 endif (BLUEZ_FOUND)
438 if (BSD_BLUE_FOUND)
439     if (NOT "${BSD_BLUE_LIBRARIES}" STREQUAL "")
440         set (GAMMU_LIBS "${GAMMU_LIBS} -l${BSD_BLUE_LIBRARIES}")
441     endif (NOT "${BSD_BLUE_LIBRARIES}" STREQUAL "")
442 endif (BSD_BLUE_FOUND)
444 if (ICONV_FOUND)
445     if (NOT "${ICONV_LIBRARIES}" STREQUAL "")
446         set (GAMMU_LIBS "${GAMMU_LIBS} -l${ICONV_LIBRARIES}")
447     endif (NOT "${ICONV_LIBRARIES}" STREQUAL "")
448 endif (ICONV_FOUND)
450 if (LIBINTL_LIB_FOUND AND LIBINTL_LIBRARIES)
451     set (GAMMU_LIBS "${GAMMU_LIBS} -l${LIBINTL_LIBRARIES}")
452 endif (LIBINTL_LIB_FOUND AND LIBINTL_LIBRARIES)
454 if (LIBUSB_FOUND)
455     if (NOT "${LIBUSB_LIBRARIES}" STREQUAL "")
456         set (GAMMU_LIBS "${GAMMU_LIBS} -l${LIBUSB_LIBRARIES}")
457     endif (NOT "${LIBUSB_LIBRARIES}" STREQUAL "")
458 endif (LIBUSB_FOUND)
460 set (SMSD_LIBS "")
462 if (MYSQL_FOUND)
463     if (NOT "${MYSQL_LIBRARIES}" STREQUAL "")
464         set (SMSD_LIBS "${SMSD_LIBS} -l${MYSQL_LIBRARIES}")
465     endif (NOT "${MYSQL_LIBRARIES}" STREQUAL "")
466 endif (MYSQL_FOUND)
468 if (POSTGRES_FOUND)
469     if (NOT "${POSTGRES_LIBRARY}" STREQUAL "")
470         set (SMSD_LIBS "${SMSD_LIBS} -l${POSTGRES_LIBRARY}")
471     endif (NOT "${POSTGRES_LIBRARY}" STREQUAL "")
472 endif (POSTGRES_FOUND)
474 # Tweak compiler flags
475 if(MSVC)
476     # MSVC needs different flags at all
477     MACRO_TUNE_COMPILER("/W3")
478 endif(MSVC)
480 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_MINGW OR
481     CMAKE_COMPILER_IS_CYGWIN OR CMAKE_COMPILER_IS_GNUCXX OR CLANG_COMPILER)
482     # Check for extra compiler flags we want to use
483     if (NOT GAMMU_VERSION_PATCH LESS 90)
484         MACRO_TUNE_COMPILER("-Werror")
485     endif (NOT GAMMU_VERSION_PATCH LESS 90)
487     #
488     # Warnings related flags
489     #
490     MACRO_TUNE_COMPILER("-Wall")
491     MACRO_TUNE_COMPILER("-Werror-implicit-function-declaration")
492     MACRO_TUNE_COMPILER("-Wno-deprecated-declarations")
493     MACRO_TUNE_COMPILER("-Wdeclaration-after-statement")
494     MACRO_TUNE_COMPILER("-Wpointer-arith")
495     MACRO_TUNE_COMPILER("-Wfloat-equal")
496     MACRO_TUNE_COMPILER("-Wbad-function-cast")
497     MACRO_TUNE_COMPILER("-Wmissing-format-attribute")
498     MACRO_TUNE_COMPILER("-Wmissing-noreturn")
499 #   This should be enabled and only public functions exported, but it is far future
500 #    MACRO_TUNE_COMPILER("-Wmissing-prototypes")
501     MACRO_TUNE_COMPILER("-Wpointer-arith")
502     MACRO_TUNE_COMPILER("-Wshadow")
503     MACRO_TUNE_COMPILER("-Wstrict-prototypes")
504     MACRO_TUNE_COMPILER("-Wsign-compare")
505 #   We need some typecasting (especially for iconv)
506 #    MACRO_TUNE_COMPILER("-Wcast-qual")
508     # Does not work well
509     #MACRO_TUNE_COMPILER("-Wunreachable-code")
511     # Just silent this for now, too much code to fix here
512     MACRO_TUNE_COMPILER("-Wno-pointer-sign")
514     # Check format strings
515     MACRO_TUNE_COMPILER("-Wshadow")
516     MACRO_TUNE_COMPILER("-Wformat=2")
517     MACRO_TUNE_COMPILER("-Wno-format-y2k")
518     MACRO_TUNE_COMPILER("-Wno-format-nonliteral")
519     # Win32 implementation of gettext does not allow us to use so strict warnings
520     if (WIN32 AND NOT CYGWIN)
521         MACRO_TUNE_COMPILER("-Wno-format-nonliteral")
522         MACRO_TUNE_COMPILER("-Wno-format-security")
523     endif (WIN32 AND NOT CYGWIN)
525     # Enable coverage if requested
526     if (NOT CLANG_COMPILER)
527         if (COVERAGE)
528             MACRO_TUNE_COMPILER_LINKER("-fprofile-arcs -ftest-coverage")
529         endif (COVERAGE)
530     endif (NOT CLANG_COMPILER)
532     # This is extremely noisy, use only in debug builds
533     if (DEBUG)
534         MACRO_TUNE_COMPILER("-Wextra")
535         if (NOT CLANG_COMPILER)
536             MACRO_TUNE_COMPILER("-Wunused-but-set-variable")
537         endif (NOT CLANG_COMPILER)
538         # Just silent this for now, too much code to fix here
539         MACRO_TUNE_COMPILER("-Wno-unused-parameter")
540         # Not sure if this is safe for all architectures
541     endif (DEBUG)
543     #
544     # Security related flags
545     #
546     if (NOT CLANG_COMPILER)
547         set (ENABLE_PROTECTION ON CACHE BOOL "Enable compile time protections (stack, read only code, fortify in libc...)")
548     endif (NOT CLANG_COMPILER)
549     if (ENABLE_PROTECTION)
550         # Need to enable -O to make fortify work
551         set (CMAKE_C_FLAGS_DEBUG "-g -O")
552         add_definitions(-D_FORTIFY_SOURCE=2)
554         # Text address randomisation, disabled for now, seems to cause problems
555         #    MACRO_TUNE_COMPILER("-fPIE")
556         #    MACRO_TUNE_LINKER("-pie")
557         # These do not work on Windows right now
558         if (NOT WIN32)
559             # Stack protector
560             MACRO_TUNE_COMPILER("-fstack-protector")
561             # Mark code read only
562             MACRO_TUNE_LINKER("-Wl,-zrelro")
563         endif (NOT WIN32)
564     endif (ENABLE_PROTECTION)
566     #
567     # Other flags
568     #
570     if (WIN32 AND NOT CYGWIN AND BUILD_SHARED_LIBS)
571         MACRO_TUNE_LINKER("-Wl,--enable-auto-import")
572     endif (WIN32 AND NOT CYGWIN AND BUILD_SHARED_LIBS)
574     MACRO_TUNE_LINKER("-Wl,--as-needed")
575     if (NOT WIN32)
576         set (PIC ON CACHE BOOL "Compile PIC code")
577         if (PIC)
578             MACRO_TUNE_COMPILER("-fPIC")
579         endif (PIC)
580     endif (NOT WIN32)
581     # Specs for MinGW to change msvcrt
582     # This is not supported by MinGW and is broken currently
583 #    if (CMAKE_COMPILER_IS_MINGW)
584 #        MACRO_TUNE_COMPILER("-specs=${CMAKE_CURRENT_SOURCE_DIR}/cmake/mingw.spec")
585 #        add_definitions(-D_MSVCRT_VERSION__=0x090)
586 #    endif (CMAKE_COMPILER_IS_MINGW)
587 endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_MINGW OR
588     CMAKE_COMPILER_IS_CYGWIN OR CMAKE_COMPILER_IS_GNUCXX OR CLANG_COMPILER)
590 if(BORLAND)
591     # Borland
592     # Suggests parenthesis
593     MACRO_TUNE_COMPILER("-wprc")
594     # Do not warn about unused params
595     MACRO_TUNE_COMPILER("-w-par")
596     # Warn about unused vars
597     MACRO_TUNE_COMPILER("-wuse")
598 endif(BORLAND)
601 # Define required libraries for gammu library if it is static
602 if (BUILD_SHARED_LIBS)
603     set (GAMMU_PRIVATE_LIBS "" CACHE INTERNAL "Private libraries for gammu library")
604     set (SMSD_PRIVATE_LIBS "" CACHE INTERNAL "Private libraries for gammu smsd library")
605 else (BUILD_SHARED_LIBS)
606     string(REGEX REPLACE "-l(/usr)?(/local)?/lib(64)?/lib([^ ]*).so" "-l\\4" G_LIB "${GAMMU_LIBS}")
607     string(REGEX REPLACE "-l(/usr)?(/local)?/lib(64)?/lib([^ ]*).so" "-l\\4" S_LIB "${SMSD_LIBS}")
608     set (GAMMU_PRIVATE_LIBS "${G_LIB}" CACHE INTERNAL "Private libraries for gammu library")
609     set (SMSD_PRIVATE_LIBS "${S_LIB}" CACHE INTERNAL "Private libraries for gammu smsd library")
610 endif (BUILD_SHARED_LIBS)
612 set (DOCS
613     README
614     ChangeLog
615     COPYING
616     )
618 # OpenCellID API key
619 set (OPENCELLID_API_KEY "2623b0e70e9fa77754a3db53f3cb6458" CACHE STRING "OpenCellID API key")
620 mark_as_advanced (OPENCELLID_API_KEY)
622 if (CMAKE_USE_PTHREADS_INIT)
623     set (HAVE_PTHREAD ON)
624 endif (CMAKE_USE_PTHREADS_INIT)
626 if (UNIX)
627     find_library (MATH_LIBRARIES m)
629     # Install paths
630     if ("${MATH_LIBRARIES}" MATCHES "/lib64/")
631         set (LIB_SUFFIX "64" CACHE STRING "Suffix of library directory (usually 64 or empty)")
632     else ("${MATH_LIBRARIES}" MATCHES "/lib64/")
633         set (LIB_SUFFIX "" CACHE STRING "Suffix of library directory (usually 64 or empty)")
634     endif ("${MATH_LIBRARIES}" MATCHES "/lib64/")
635 endif (UNIX)
638 set (INSTALL_BIN_DIR "bin" CACHE STRING "Path for binaries installation")
639 mark_as_advanced (INSTALL_BIN_DIR)
641 set (INSTALL_LIB_DIR "lib${LIB_SUFFIX}" CACHE STRING "Path for libraries installation")
642 mark_as_advanced (INSTALL_LIB_DIR)
644 set (INSTALL_LIBDATA_DIR "lib${LIB_SUFFIX}" CACHE STRING "Path for libraries data (eg. pkgconfig data) installation")
645 mark_as_advanced (INSTALL_LIBDATA_DIR)
647 set (INSTALL_INC_DIR "include/gammu" CACHE STRING "Path for includes installation")
648 mark_as_advanced (INSTALL_INC_DIR)
650 set (INSTALL_LOC_DIR "share/locale" CACHE STRING "Path for locales installation")
651 mark_as_advanced (INSTALL_LOC_DIR)
653 set (INSTALL_DATA_DIR "share/gammu" CACHE STRING "Path for data installation")
654 mark_as_advanced (INSTALL_DATA_DIR)
656 set (INSTALL_DOC_DIR "share/doc/gammu" CACHE STRING "Path for documentation installation")
657 mark_as_advanced (INSTALL_DOC_DIR)
659 set (INSTALL_MAN_DIR "share/man" CACHE STRING "Path for man pages installation")
660 mark_as_advanced (INSTALL_MAN_DIR)
662 # Phone and protocol configuration
664 # Nokia phones
665 macro_gammu_option (NOKIA_SUPPORT "Nokia support" ON ON ON)
667 macro_gammu_option (MBUS2 "Nokia MBUS2 protocol" ON WITH_NOKIA_SUPPORT ON)
668 macro_gammu_option (FBUS2 "Nokia FBUS2 protocol" ON WITH_NOKIA_SUPPORT ON)
669 macro_gammu_option (FBUS2DLR3 "Nokia FBUS2DLR3 protocol" ON WITH_NOKIA_SUPPORT ON)
670 macro_gammu_option (DKU2PHONET "Nokia DKU2PHONET protocol" ON WITH_NOKIA_SUPPORT ON)
671 macro_gammu_option (DKU2AT "Nokia DKU2AT protocol" ON WITH_NOKIA_SUPPORT ON)
672 macro_gammu_option (DKU5FBUS2 "Nokia DKU5FBUS2 protocol" ON WITH_NOKIA_SUPPORT ON)
673 macro_gammu_option (FBUS2PL2303 "Nokia FBUS2PL2303 protocol" ON WITH_NOKIA_SUPPORT ON)
675 macro_gammu_option (FBUS2BLUE "Nokia FBUS2BLUE protocol" ON WITH_NOKIA_SUPPORT BLUETOOTH_FOUND)
676 macro_gammu_option (PHONETBLUE "Nokia PHONETBLUE protocol" ON WITH_NOKIA_SUPPORT BLUETOOTH_FOUND)
677 macro_gammu_option (BLUEFBUS2 "Nokia BLUEFBUS2 protocol" ON WITH_NOKIA_SUPPORT BLUETOOTH_FOUND)
678 macro_gammu_option (BLUEPHONET "Nokia BLUEPHONET protocol" ON WITH_NOKIA_SUPPORT BLUETOOTH_FOUND)
680 macro_gammu_option (IRDAPHONET "Nokia IRDAPHONET protocol" ON WITH_NOKIA_SUPPORT IRDA_FOUND)
681 macro_gammu_option (FBUS2IRDA "Nokia FBUS2IRDA protocol" ON WITH_NOKIA_SUPPORT IRDA_FOUND)
683 macro_gammu_option (NOKIA3320 "Nokia 3320 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
684 macro_gammu_option (NOKIA650 "Nokia 650 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
685 macro_gammu_option (NOKIA6110 "Nokia 61xx and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
686 macro_gammu_option (NOKIA6510 "Nokia 6510 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
687 macro_gammu_option (DCT4_CALENDAR_6210 "Force using 6210 frames for calendar for DCT4 phones" OFF WITH_NOKIA_SUPPORT WITH_NOKIA6510)
688 if (WITH_DCT4_CALENDAR_6210)
689     set (GSM_FORCE_DCT4_CALENDAR_6210 TRUE)
690 endif (WITH_DCT4_CALENDAR_6210)
691 macro_gammu_option (NOKIA7110 "Nokia 7110 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
692 macro_gammu_option (NOKIA9210 "Nokia 9210 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
693 if (WITH_NOKIA7110 OR WITH_NOKIA9210)
694     set (wITH_71_92 ON)
695 else (WITH_NOKIA7110 OR WITH_NOKIA9210)
696     set (wITH_71_92)
697 endif (WITH_NOKIA7110 OR WITH_NOKIA9210)
698 macro_gammu_option (N71_92INCOMINGINFO "Nokia 62xx/71xx/9xxx incoming call/SMS info" OFF WITH_NOKIA_SUPPORT WITH_71_92)
699 macro_gammu_option (NOKIA3650 "Nokia 3650 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
701 # AT phones
702 macro_gammu_option (AT_SUPPORT "AT support" ON ON ON)
704 macro_gammu_option (AT "AT protocol" ON WITH_AT_SUPPORT ON)
705 macro_gammu_option (BLUEAT "AT protocol over Bluetooth" ON WITH_AT_SUPPORT BLUETOOTH_FOUND)
706 macro_gammu_option (IRDAAT "AT protocol over IrDA" ON WITH_AT_SUPPORT IRDA_FOUND)
708 macro_gammu_option (ATGEN "AT phones support" ON WITH_AT_SUPPORT ON)
710 macro_gammu_option (ALCATEL_SUPPORT "Alcatel support" ON WITH_AT_SUPPORT ON)
712 macro_gammu_option (ALCABUS "Alcatel protocol" ON WITH_ALCATEL_SUPPORT ON)
714 macro_gammu_option (ALCATEL "Alcatel phones support" ON WITH_ALCATEL_SUPPORT ON)
716 # OBEX phones
717 macro_gammu_option (OBEX_SUPPORT "OBEX compatible phones support" ON ON ON)
719 macro_gammu_option (BLUEOBEX "OBEX protocol over Bluetooth" ON WITH_OBEX_SUPPORT BLUETOOTH_FOUND)
720 macro_gammu_option (IRDAOBEX "OBEX protocol over IrDA" ON WITH_OBEX_SUPPORT IRDA_FOUND)
722 macro_gammu_option (OBEXGEN "Generic OBEX phones support" ON WITH_OBEX_SUPPORT ON)
723 macro_gammu_option (ATOBEX "AT with OBEX phones support" ON WITH_OBEX_SUPPORT WITH_AT_SUPPORT)
724 macro_gammu_option (ATOBEX_AUTO_MODE "Automatic switching to OBEX for AT+MODE capable phones" OFF WITH_ATOBEX_SUPPORT ON)
726 macro_gammu_option (S60_SUPPORT "Symbian phones support (S60)" ON ON ON)
727 macro_gammu_option (GNAPPLET_SUPPORT "Symbian phones support (gnapplet)" ON WITH_NOKIA_SUPPORT ON)
728 macro_gammu_option (BLUEGNAPBUS "GNAPBUS protocol over Bluetooth" ON WITH_GNAPPLET_SUPPORT BLUETOOTH_FOUND)
729 macro_gammu_option (IRDAGNAPBUS "GNAPBUS protocol over IrDA" ON WITH_GNAPPLET_SUPPORT IRDA_FOUND)
731 macro_gammu_option (GNAPGEN "Gnapplet phones support" ON WITH_GNAPPLET_SUPPORT ON)
733 macro_gammu_option (S60 "S60 phones support" ON WITH_S60_SUPPORT ON)
735 # Some generic configurations
736 macro_gammu_option (CELLBROADCAST "Cell Broadcast messages support" ON ON ON)
737 macro_gammu_option (BACKUP "Backup/Restore functions" ON ON ON)
739 # Generate Doxygen file
740 set (DOXYGEN_INPUT "${CMAKE_CURRENT_BINARY_DIR}/include")
741 set (DOXYGEN_INTERNAL_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/libgammu")
742 set (DOXYGEN_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gammu-doc")
743 set (DOXYGEN_INTERNAL_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gammu-internal-doc")
744 if ("${DOXYGEN_DOT_EXECUTABLE}" STREQUAL DOXYGEN_DOT_EXECUTABLE-NOTFOUND)
745     set (HAVE_DOT "NO")
746     set (DOXYGEN_DOT_PATH "")
747 else ("${DOXYGEN_DOT_EXECUTABLE}" STREQUAL DOXYGEN_DOT_EXECUTABLE-NOTFOUND)
748     set (HAVE_DOT "YES")
749     # Strip binary name from variable
750     string (REGEX REPLACE "/dot$" "" DOXYGEN_DOT_PATH "${DOXYGEN_DOT_EXECUTABLE}")
751 endif ("${DOXYGEN_DOT_EXECUTABLE}" STREQUAL DOXYGEN_DOT_EXECUTABLE-NOTFOUND)
752 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/Doxyfile.cmake" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/Doxyfile")
753 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/Doxyfile-internal.cmake" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/Doxyfile-internal")
754 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/api.desc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/api.desc")
755 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/internals.desc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/internals.desc")
757 # Target for generating API documentation
758 add_custom_target (apidoc ${DOXYGEN_EXECUTABLE} doxygen/Doxyfile
759     COMMAND find ${DOXYGEN_OUTPUT}/html -name '*.html' -print0 | xargs -0 sed -i 's@text/html\;charset=iso-8859-1@text/html\;charset=utf-8@'
760     COMMENT "Generating API documentation")
762 add_custom_target (interndoc ${DOXYGEN_EXECUTABLE} doxygen/Doxyfile-internal
763     COMMAND find ${DOXYGEN_INTERNAL_OUTPUT}/html -name '*.html' -print0 | xargs -0 sed -i 's@text/html\;charset=iso-8859-1@text/html\;charset=utf-8@'
764     COMMENT "Generating internal documentation")
766 # CPP check
767 find_program(CPPCHECK_EXECUTABLE NAMES cppcheck
768     DOC "cppcheck - code checking tool")
769 add_custom_target (cppcheck ${CPPCHECK_EXECUTABLE} -a -f -q "${CMAKE_CURRENT_SOURCE_DIR}/gammu" "${CMAKE_CURRENT_SOURCE_DIR}/smsd" "${CMAKE_CURRENT_SOURCE_DIR}/helper" "${CMAKE_CURRENT_SOURCE_DIR}/libgammu" "${CMAKE_CURRENT_SOURCE_DIR}/python/gammu/src" "${CMAKE_CURRENT_SOURCE_DIR}/tests" "${CMAKE_CURRENT_SOURCE_DIR}/docs/manual/examples" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/smscgi"
770     COMMENT "Checking C code")
773 # Generate pkgconfig file
774 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gammu.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cfg/gammu.pc" @ONLY)
775 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gammu-smsd.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cfg/gammu-smsd.pc" @ONLY)
776 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gammu-uninstalled.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/gammu.pc" @ONLY)
777 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gammu-smsd-uninstalled.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/gammu-smsd.pc" @ONLY)
779 # Install instructions
781 # Install Windows libraries
782 if (WIN32 AND NOT CYGWIN)
783     # MySQL
784     if (MYSQL_FOUND)
785         foreach(lib ${WIN_LIB_MYSQL})
786             ADD_DLL("${lib}" "${MYSQL_LIBRARIES}")
787         endforeach(lib ${WIN_LIB_MYSQL})
788     endif (MYSQL_FOUND)
790     # PostgreSQL and dependencies
791     if (POSTGRES_FOUND)
792         foreach(lib ${WIN_LIB_PGSQL})
793             ADD_DLL("${lib}" "${POSTGRES_LIBRARY}")
794         endforeach(lib ${WIN_LIB_PGSQL})
795     endif (POSTGRES_FOUND)
797     # iconv and dependencies
798     if (ICONV_FOUND)
799         foreach(lib ${WIN_LIB_ICONV})
800             ADD_DLL("${lib}" "${ICONV_LIBRARIES}")
801         endforeach(lib ${WIN_LIB_ICONV})
802     endif (ICONV_FOUND)
804     # Gettext and dependencies
805     if (LIBINTL_LIB_FOUND)
806         foreach(lib ${WIN_LIB_INTL})
807             ADD_DLL("${lib}" "${LIBINTL_LIBRARY}")
808         endforeach(lib ${WIN_LIB_INTL})
809     endif (LIBINTL_LIB_FOUND)
811     # Curl and dependencies
812     if (CURL_FOUND)
813         foreach(lib ${WIN_LIB_CURL})
814             ADD_DLL("${lib}" "${CURL_LIBRARIES}")
815         endforeach(lib ${WIN_LIB_CURL})
816     endif (CURL_FOUND)
818     # Glib and dependencies
819     if (GLIB_FOUND)
820         foreach(lib ${WIN_LIB_GLIB})
821             ADD_DLL("${lib}" "${GLIB_LIBRARIES}")
822         endforeach(lib ${WIN_LIB_GLIB})
823     endif (GLIB_FOUND)
825     install (FILES ${WIN32_INSTALL_DLL}
826             DESTINATION "${INSTALL_BIN_DIR}"
827             COMPONENT dlls
828             )
829 endif (WIN32 AND NOT CYGWIN)
831 install (
832     FILES "${CMAKE_CURRENT_BINARY_DIR}/cfg/gammu.pc" "${CMAKE_CURRENT_BINARY_DIR}/cfg/gammu-smsd.pc"
833     DESTINATION "${INSTALL_LIBDATA_DIR}/pkgconfig"
834     COMPONENT "pkgconfig"
835     )
837 # We want some tests. Even when cross compiling for Windows tests can be
838 # done in Wine. This is better than nothing, even though Wine is a bit
839 # more fault tolerant when linking DLLs.
841 # Valgrind supressions for python
842 set (MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/valgrind-python.supp CACHE FILEPATH "File that contains suppressions for the memory checker")
844 # Testing and dashboard
845 include(CTest)
846 enable_testing()
847 include(Dart)
849 # Packaging support
850 set (CPACK_PACKAGE_NAME "Gammu")
851 set (CPACK_PACKAGE_VERSION "${GAMMU_VERSION}")
852 set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gammu All Mobile Management Utilities ${GAMMU_VERSION}")
853 set (CPACK_PACKAGE_VENDOR "Michal Čihař")
854 set (CPACK_PACKAGE_CONTACT "Michal Čihař <michal@cihar.com>")
855 set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/installer/description.txt")
856 # On Mac OS, the file needs .txt extension, give it to them
857 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/readme.txt" COPYONLY)
858 set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_BINARY_DIR}/readme.txt")
859 set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/installer/license.txt")
860 set (CPACK_PACKAGE_VERSION_MAJOR "${GAMMU_VERSION_MAJOR}")
861 set (CPACK_PACKAGE_VERSION_MINOR "${GAMMU_VERSION_MINOR}")
862 set (CPACK_PACKAGE_VERSION_PATCH "${GAMMU_VERSION_PATCH}")
863 set (CPACK_INSTALLER_PROGRAM_DISK_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/installer/addpostflight")
865 if (WIN32 AND NOT CYGWIN)
866     set (CPACK_SYSTEM_NAME "Windows" CACHE STRING "Windows package name")
867 endif (WIN32 AND NOT CYGWIN)
869 # RPM
870 set (CPACK_RPM_PACKAGE_LICENSE "GPLv2")
871 if (EXISTS "/etc/SuSE-release")
872 set (CPACK_RPM_PACKAGE_GROUP "Hardware/Mobile")
873 else (EXISTS "/etc/SuSE-release")
874 set (CPACK_RPM_PACKAGE_GROUP "Applications/Communications")
875 endif (EXISTS "/etc/SuSE-release")
877 # Components
878 set (CPACK_COMPONENTS_ALL gammu library smsd headers utils manpages docs pkgconfig symbian examples manual)
879 if (WITH_PYTHON)
880     list (APPEND CPACK_COMPONENTS_ALL python)
881 endif (WITH_PYTHON)
882 if (WIN32 AND NOT CYGWIN AND WIN32_INSTALL_DLL)
883     list (APPEND CPACK_COMPONENTS_ALL dlls)
884 endif (WIN32 AND NOT CYGWIN AND WIN32_INSTALL_DLL)
886 set (CPACK_COMPONENT_GAMMU_DISPLAY_NAME "Gammu Application")
887 set (CPACK_COMPONENT_SMSD_DISPLAY_NAME "Gammu SMS Daemon")
888 set (CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Gammu Library")
889 set (CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C Headers")
890 set (CPACK_COMPONENT_UTILS_DISPLAY_NAME "Utility Scripts")
891 set (CPACK_COMPONENT_MANPAGES_DISPLAY_NAME "Manual Pages")
892 set (CPACK_COMPONENT_DOCS_DISPLAY_NAME "User Documentation")
893 set (CPACK_COMPONENT_PKGCONFIG_DISPLAY_NAME "Pkg-config Data")
894 set (CPACK_COMPONENT_SYMBIAN_DISPLAY_NAME "Applet for Symbian Phones")
895 set (CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Examples Using Gammu")
896 set (CPACK_COMPONENT_MANUAL_DISPLAY_NAME "Gammu Manual")
897 set (CPACK_COMPONENT_PYTHON_DISPLAY_NAME "Python Module")
898 set (CPACK_COMPONENT_MEDIA_DISPLAY_NAME "Media Files")
900 set (CPACK_COMPONENT_DLLS_HIDDEN TRUE)
901 set (CPACK_COMPONENT_DLLS_REQUIRED TRUE)
902 set (CPACK_COMPONENT_LIBRARY_REQUIRED TRUE)
904 set (CPACK_COMPONENT_GAMMU_DESCRIPTION "The gammu.exe program.")
905 set (CPACK_COMPONENT_SMSD_DESCRIPTION "Gammu SMS Daemon which automatically sends and receives messages.")
906 set (CPACK_COMPONENT_LIBRARY_DESCRIPTION "Gammu library.")
907 set (CPACK_COMPONENT_HEADERS_DESCRIPTION "C headers for development own programs using Gammu library.")
908 set (CPACK_COMPONENT_UTILS_DESCRIPTION "Utility scripts, mostly written using bourne shell, which you need to install on your own.")
909 set (CPACK_COMPONENT_MANPAGES_DESCRIPTION "Manual pages for programs and configuration files.")
910 set (CPACK_COMPONENT_DOCS_DESCRIPTION "User documentation in text files.")
911 set (CPACK_COMPONENT_PKGCONFIG_DESCRIPTION "Data for pkg-config program (automatic finding of compiler parameters for libraries).")
912 set (CPACK_COMPONENT_SYMBIAN_DESCRIPTION "Applet for Symbian phones, install it to phone to communicate with them using Gammu.")
913 set (CPACK_COMPONENT_EXAMPLES_DESCRIPTION "Examples showing how to use Gammu, in PHP, Perl or C.")
914 set (CPACK_COMPONENT_MANUAL_DESCRIPTION "User and Developer Manual")
915 set (CPACK_COMPONENT_PYTHON_DESCRIPTION "Python module for Gammu.")
916 set (CPACK_COMPONENT_MEDIA_DESCRIPTION "Various media files which can be used with Gammu.")
918 set (CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "Programs and libraries for general usage.")
919 set (CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "Headers and documentation used for development using Gammu.")
920 set (CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION "Gammu documentation and usage examples.")
922 set(CPACK_COMPONENT_GAMMU_DEPENDS library)
923 if (WIN32 AND NOT CYGWIN AND WIN32_INSTALL_DLL)
924 set(CPACK_COMPONENT_LIBRARY_DEPENDS dlls)
925 endif (WIN32 AND NOT CYGWIN AND WIN32_INSTALL_DLL)
926 set(CPACK_COMPONENT_SMSD_DEPENDS library)
927 set(CPACK_COMPONENT_HEADERS_DEPENDS library)
928 set(CPACK_COMPONENT_PYTHON_DEPENDS library)
929 set(CPACK_COMPONENT_UTILS_DEPENDS gammu)
930 set(CPACK_COMPONENT_PKGCONFIG_DEPENDS headers)
932 set (CPACK_COMPONENT_GAMMU_GROUP "Runtime")
933 set (CPACK_COMPONENT_SMSD_GROUP "Runtime")
934 set (CPACK_COMPONENT_UTILS_GROUP "Runtime")
935 set (CPACK_COMPONENT_LIBRARY_GROUP "Runtime")
936 set (CPACK_COMPONENT_PYTHON_GROUP "Runtime")
938 set (CPACK_COMPONENT_HEADERS_GROUP "Development")
939 set (CPACK_COMPONENT_PKGCONFIG_GROUP "Development")
941 set (CPACK_COMPONENT_MANPAGES_GROUP "Documentation")
942 set (CPACK_COMPONENT_DOCS_GROUP "Documentation")
943 set (CPACK_COMPONENT_EXAMPLES_GROUP "Documentation")
944 set (CPACK_COMPONENT_MANUAL_GROUP "Documentation")
945 set (CPACK_COMPONENT_MEDIA_GROUP "Documentation")
947 set (CPACK_ALL_INSTALL_TYPES Standard Developer Full)
949 set (CPACK_COMPONENT_GAMMU_INSTALL_TYPES Standard Developer Full)
950 set (CPACK_COMPONENT_SMSD_INSTALL_TYPES Standard Developer Full)
951 set (CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Standard Developer Full)
952 set (CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
953 set (CPACK_COMPONENT_UTILS_INSTALL_TYPES Full)
954 set (CPACK_COMPONENT_MANPAGES_INSTALL_TYPES Standard Developer Full)
955 set (CPACK_COMPONENT_DOCS_INSTALL_TYPES Standard Developer Full)
956 set (CPACK_COMPONENT_PKGCONFIG_INSTALL_TYPES Developer Full)
957 set (CPACK_COMPONENT_SYMBIAN_INSTALL_TYPES Standard Developer Full)
958 set (CPACK_COMPONENT_EXAMPLES_INSTALL_TYPES Developer Full)
959 set (CPACK_COMPONENT_MANUAL_INSTALL_TYPES Developer Full)
960 set (CPACK_COMPONENT_PYTHON_INSTALL_TYPES Developer Full)
961 set (CPACK_COMPONENT_MEDIA_INSTALL_TYPES Full)
963 if (WIN32 AND NOT CYGWIN)
964   set (CPACK_PACKAGE_INSTALL_DIRECTORY "Gammu ${GAMMU_VERSION}")
965   set (CPACK_NSIS_DISPLAY_NAME "Gammu ${GAMMU_VERSION}")
966   set (CPACK_NSIS_HELP_LINK "http://wammu.eu/support/")
967   set (CPACK_NSIS_URL_INFO_ABOUT "http://wammu.eu/gammu/")
968   set (CPACK_NSIS_CONTACT "michal@cihar.com")
969   set (CPACK_NSIS_MODIFY_PATH ON)
970 else (WIN32 AND NOT CYGWIN)
971   set (CPACK_STRIP_FILES "gammu")
972   set (CPACK_SOURCE_STRIP_FILES "")
973 endif (WIN32 AND NOT CYGWIN)
974 include (CPack)
976 # Test files for Gammu
977 set (RINGTONE_TEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/media/axelf.txt)
978 set (LOGO_TEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/media/aliens.nlm)
980 # Transverse to dirs
981 add_subdirectory(include)
983 add_subdirectory(libgammu)
985 add_subdirectory(helper)
987 add_subdirectory(tests)
989 add_subdirectory(smsd)
991 add_subdirectory(gammu)
993 add_subdirectory(gammu-detect)
995 add_subdirectory(locale)
997 add_subdirectory(utils)
999 option(INSTALL_DOC "Install documentation" ON)
1001 if(INSTALL_DOC)
1002     install (
1003         FILES ${DOCS}
1004         DESTINATION "${INSTALL_DOC_DIR}"
1005         COMPONENT "docs"
1006         )
1008     add_subdirectory(docs/config)
1009     add_subdirectory(docs/manual)
1010     add_subdirectory(docs/examples)
1011     add_subdirectory(docs/sql)
1012     add_subdirectory(docs/man)
1013 endif(INSTALL_DOC)
1015 add_subdirectory(contrib)
1017 if (WITH_PYTHON)
1018     add_subdirectory(python)
1019 else (WITH_PYTHON)
1020     message ("Python bindings are disabled!")
1021 endif (WITH_PYTHON)