Merge remote-tracking branch 'weblate/master'
[gammu.git] / CMakeLists.txt
blob1f16253653a7f005d365f7c46f12e47c06e8a0c3
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.31.91" 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 (SIGUSR1 "signal.h" HAVE_SIGUSR1)
149 check_symbol_exists (SIGUSR2 "signal.h" HAVE_SIGUSR2)
150 check_symbol_exists (dup "unistd.h" HAVE_DUP_UNISTD_H)
151 check_symbol_exists (getpid "unistd.h" HAVE_GETPID)
152 check_symbol_exists (getpass "unistd.h" HAVE_GETPASS)
153 check_symbol_exists (alarm "unistd.h" HAVE_ALARM)
154 check_symbol_exists (dup "io.h" HAVE_DUP_IO_H)
155 check_symbol_exists (shmget "sys/shm.h" HAVE_SHM)
156 check_c_source_compiles ("
157 #define _XOPEN_SOURCE
158 #define _BSD_SOURCE
159 #include <time.h>
161 int main(void) {
162     struct tm timestruct;
163     strptime(\"11:22\", \"%H:%M\", &timestruct);
164     return 0;
165 }" HAVE_STRPTIME)
166 check_c_source_compiles ("
167 #include <stdio.h>
168 #include <syslog.h>
169 #include <stdarg.h>
171 int main(void) {
172     syslog(LOG_NOTICE, \"aaa %d\", 1);
173     return 0;
175 "  HAVE_SYSLOG)
176 # Some compilers (eg. BCC) have this in ctype.h
177 if (NOT HAVE_TOWLOWER)
178     check_symbol_exists (towlower "ctype.h" HAVE_TOWLOWER_CTYPE)
179     if (HAVE_TOWLOWER_CTYPE)
180         set (HAVE_TOWLOWER ${HAVE_TOWLOWER_CTYPE} CACHE INTERNAL "")
181     endif (HAVE_TOWLOWER_CTYPE)
182 endif (NOT HAVE_TOWLOWER)
184 # Standard packages
185 macro_optional_find_package (Threads)
187 # Used (optionally for testing)
188 find_program(SH_BIN sh)
189 find_program(BASH_BIN bash)
190 find_program(SQLITE_BIN sqlite3)
191 find_program(SED_BIN sed)
192 find_program(MYSQL_BIN mysql)
193 find_program(PSQL_BIN psql)
195 # Check for Python
196 set (BUILD_PYTHON "" CACHE FILEPATH "Path to python interpreter")
198 if (BUILD_PYTHON)
199     set (WITH_PYTHON TRUE CACHE BOOL "Build Python bindings")
200     set (PYTHON_EXECUTABLE ${BUILD_PYTHON})
201     execute_process(
202         COMMAND
203             ${PYTHON_EXECUTABLE} -c "import sys; print('.'.join([str(x) for x in sys.version_info[:2]]))"
204         OUTPUT_VARIABLE PYTHON_VERSION
205         OUTPUT_STRIP_TRAILING_WHITESPACE
206         )
207     if("${PYTHON_VERSION}" STREQUAL "")
208         message(FATAL_ERROR "Failed to execute defined Python: ${BUILD_PYTHON}")
209     endif("${PYTHON_VERSION}" STREQUAL "")
211     message (STATUS "Compiling for Python ${PYTHON_VERSION}")
212     execute_process(
213         COMMAND
214             ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())"
215         OUTPUT_VARIABLE PYTHON_INCLUDE_PATH
216         OUTPUT_STRIP_TRAILING_WHITESPACE
217         )
219     string (REPLACE "." "" PYTHON_VERSION_NO_DOTS "${PYTHON_VERSION}")
220     find_library (PYTHON_LIBRARY
221         NAMES python${PYTHON_VERSION_NO_DOTS} python${PYTHON_VERSION}
222         PATHS
223           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION}\\InstallPath]/libs
224         PATH_SUFFIXES
225           python${PYTHON_VERSION}/config
226         # Avoid finding the .dll in the PATH.  We want the .lib.
227         NO_SYSTEM_ENVIRONMENT_PATH
228       )
229 else (BUILD_PYTHON)
230     find_package(PythonInterp)
231     find_package(PythonLibs)
233     if (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
234         set (WITH_PYTHON TRUE CACHE BOOL "Build Python bindings")
235     else (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
236         set (WITH_PYTHON FALSE CACHE BOOL "Build Python bindings" FORCE)
237     endif (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
238 endif (BUILD_PYTHON)
240 if (PYTHON_EXECUTABLE)
241     execute_process(
242         COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print(sys.version_info[0])"
243         OUTPUT_VARIABLE PYTHON_MAJOR_VERSION
244         OUTPUT_STRIP_TRAILING_WHITESPACE
245         )
246     if ("${PYTHON_MAJOR_VERSION}" GREATER 2)
247         message("Python 3.x is not currently supported!")
248         set (WITH_PYTHON FALSE CACHE BOOL "Build Python bindings" FORCE)
249     endif ("${PYTHON_MAJOR_VERSION}" GREATER 2)
250 endif (PYTHON_EXECUTABLE)
252 # Packages in sources
253 macro_optional_find_package (MySQL)
254 macro_optional_find_package (ODBC)
255 macro_optional_find_package (Postgres)
256 macro_optional_find_package (LibDBI)
257 macro_optional_find_package (Libintl)
258 macro_optional_find_package (Iconv)
259 macro_optional_find_package (CURL)
260 macro_optional_find_package (Glib)
261 macro_optional_find_package (Gobject)
263 # Gudev stuff
264 pkg_check_modules(GUDEV gudev-1.0)
266 if (CMAKE_CROSSCOMPILING AND MINGW)
267     set (HAVE_WINT_T 4 CACHE INTERNAL "")
268     set (HAVE_WCHAR_T 4 CACHE INTERNAL "")
269 else (CMAKE_CROSSCOMPILING AND MINGW)
270     # Search for needed includes and functions
271     if (HAVE_WCHAR_H)
272         set (CMAKE_EXTRA_INCLUDE_FILES wchar.h)
273         check_type_size (wchar_t HAVE_WCHAR_T)
274         check_type_size (wint_t  HAVE_WINT_T)
275     endif (HAVE_WCHAR_H)
276     set (CMAKE_EXTRA_INCLUDE_FILES)
277 endif (CMAKE_CROSSCOMPILING AND MINGW)
279 set (CMAKE_EXTRA_INCLUDE_FILES stdio.h)
280 check_type_size (ssize_t HAVE_SSIZE_T)
281 set (CMAKE_EXTRA_INCLUDE_FILES)
282 if (HAVE_UNISTD_H)
283     set (CMAKE_EXTRA_INCLUDE_FILES unistd.h)
284     check_type_size(intptr_t HAVE_INTPTR_T)
285     set (CMAKE_EXTRA_INCLUDE_FILES)
286 else(HAVE_UNISTD_H)
287     check_type_size(intptr_t HAVE_INTPTR_T)
288 endif (HAVE_UNISTD_H)
290 check_c_source_compiles ("
291 #include <stdio.h>
293 int main(void) {
294     printf( __FUNCTION__);
295     return 0;
297 "  HAVE_MACRO_FUNCTION)
299 check_c_source_compiles ("
300 #include <time.h>
302 int main(void) {
303     struct tm tm;
304     tm.tm_zone;
305     return 0;
307 "  HAVE_STRUCT_TM_TM_ZONE)
309 check_c_source_compiles ("
310 #include <time.h>
312 int main(void) {
313     struct tm tm;
314         tm.tm_isdst     = daylight;
315     return 0;
317 "  HAVE_DAYLIGHT)
319 check_c_source_compiles ("
320 #include <stdio.h>
322 int main(void) {
323     printf( __FUNC__);
324     return 0;
326 "  HAVE_MACRO_FUNC)
329 OPTION(WITH_BLUETOOTH "Bluetooth support" ON)
330 if (WITH_BLUETOOTH)
331     if (WIN32 AND NOT CYGWIN)
332         # FIXME: This is currently hardcoded here, maybe there is test?
333         set(BLUETOOTH_FOUND ON)
334         message(STATUS "Using Windows native Bluetooth")
335         set(BLUETOOTH_SEARCH TRUE)
336     elseif(CYGWIN)
337         message(STATUS "Bluetooth is currently not supported in Cygwin")
338         message(STATUS "If you need it, contact us")
339     else (WIN32 AND NOT CYGWIN)
340         find_package (Bluez)
341         if (BLUEZ_FOUND)
342             set(BLUETOOTH_FOUND ON)
343             set(BLUETOOTH_SEARCH TRUE)
344             message(STATUS "Using BlueZ stack")
345         endif (BLUEZ_FOUND)
346         find_package (BSDBluetooth)
347         if (BSD_BLUE_FOUND)
348             set(BLUETOOTH_FOUND ON)
349             message(STATUS "Using BSD Bluetooth stack")
350             check_library_exists(bluetooth sdp_service_search_attribute "" HAVE_SDP_SERVICE_SEARCH_ATTRIBUTE)
351             check_library_exists(bluetooth bt_devinquiry "" HAVE_BT_DEVINQUIRY)
352             if (HAVE_SDP_SERVICE_SEARCH_ATTRIBUTE AND HAVE_BT_DEVINQUIRY)
353                 set(BLUETOOTH_SEARCH TRUE)
354             endif (HAVE_SDP_SERVICE_SEARCH_ATTRIBUTE AND HAVE_BT_DEVINQUIRY)
355         endif (BSD_BLUE_FOUND)
356         find_package (OSXBluetooth)
357         if (OSX_BLUE_FOUND)
358             set(BLUETOOTH_FOUND ON)
359             set(BLUETOOTH_SEARCH FALSE)
360             message(STATUS "Using OSX Bluetooth stack")
361         endif (OSX_BLUE_FOUND)
362     endif (WIN32 AND NOT CYGWIN)
363 else (WITH_BLUETOOTH)
364     set(BLUETOOTH_FOUND FALSE)
365     set(BLUETOOTH_INCLUDE_DIR)
366     set(BLUETOOTH_INCLUDES)
367     set(BLUETOOTH_LIBRARY)
368     set(BLUETOOTH_LIBRARIES)
369 endif (WITH_BLUETOOTH)
371 if (BLUETOOTH_FOUND)
372     message(STATUS "Bluetooth support enabled")
373 else (BLUETOOTH_FOUND)
374     if (WITH_BLUETOOTH AND NOT CYGWIN)
375         message("Bluetooth support disabled, please install libbluetooth-dev or equivalent to enable Bluetooth.")
376     endif (WITH_BLUETOOTH AND NOT CYGWIN)
377 endif (BLUETOOTH_FOUND)
379 macro_gammu_option (BLUETOOTH_RF_SEARCHING "Searching for RF channels with Bluetooth stack" ON BLUETOOTH_FOUND BLUETOOTH_SEARCH)
380 if (WITH_BLUETOOTH_RF_SEARCHING)
381     set (BLUETOOTH_RF_SEARCHING ON)
382 endif (WITH_BLUETOOTH_RF_SEARCHING)
384 OPTION(WITH_USB "Native USB support" ON)
385 if (WITH_USB)
386     find_package (LibUSB)
387 endif (WITH_USB)
389 OPTION(WITH_IRDA "IrDA support" ON)
390 if (WITH_IRDA)
391     if (WIN32 AND NOT CYGWIN)
392         # FIXME: This is currently hardcoded here, maybe there is test?
393         set (IRDA_FOUND TRUE)
394         message(STATUS "Using Windows native IrDA")
395     elseif(CYGWIN)
396         message(STATUS "IrDA is currently not supported in Cygwin")
397         message(STATUS "If you need it, contact us")
398         set (IRDA_FOUND FALSE)
399     else (WIN32 AND NOT CYGWIN)
400         check_c_source_compiles (
401             "
402 #include <sys/socket.h>
403 #include <linux/types.h>
404 #include <sys/ioctl.h>
405 #include <linux/irda.h>
406     int main(int argc, char **argv) {
407         return 0;
408     }
409             "
410             IRDA_FOUND
411             )
412         if (IRDA_FOUND)
413             message(STATUS "Using Linux native IrDA")
414         endif (IRDA_FOUND)
415     endif (WIN32 AND NOT CYGWIN)
416 else (WITH_IRDA)
417     set (IRDA_FOUND FALSE)
418 endif (WITH_IRDA)
420 if (IRDA_FOUND)
421     message(STATUS "IrDA support enabled")
422 endif (IRDA_FOUND)
424 if (MYSQL_FOUND)
425     set (HAVE_MYSQL_MYSQL_H TRUE)
426 endif (MYSQL_FOUND)
428 if (POSTGRES_FOUND)
429     set (HAVE_POSTGRESQL_LIBPQ_FE_H TRUE)
430 endif (POSTGRES_FOUND)
432 set (GAMMU_LIBS "")
434 if (BLUEZ_FOUND)
435     if (NOT "${BLUEZ_LIBRARIES}" STREQUAL "")
436         set (GAMMU_LIBS "${GAMMU_LIBS} -l${BLUEZ_LIBRARIES}")
437     endif (NOT "${BLUEZ_LIBRARIES}" STREQUAL "")
438 endif (BLUEZ_FOUND)
440 if (BSD_BLUE_FOUND)
441     if (NOT "${BSD_BLUE_LIBRARIES}" STREQUAL "")
442         set (GAMMU_LIBS "${GAMMU_LIBS} -l${BSD_BLUE_LIBRARIES}")
443     endif (NOT "${BSD_BLUE_LIBRARIES}" STREQUAL "")
444 endif (BSD_BLUE_FOUND)
446 if (ICONV_FOUND)
447     if (NOT "${ICONV_LIBRARIES}" STREQUAL "")
448         set (GAMMU_LIBS "${GAMMU_LIBS} -l${ICONV_LIBRARIES}")
449     endif (NOT "${ICONV_LIBRARIES}" STREQUAL "")
450 endif (ICONV_FOUND)
452 if (LIBINTL_LIB_FOUND AND LIBINTL_LIBRARIES)
453     set (GAMMU_LIBS "${GAMMU_LIBS} -l${LIBINTL_LIBRARIES}")
454 endif (LIBINTL_LIB_FOUND AND LIBINTL_LIBRARIES)
456 if (LIBUSB_FOUND)
457     if (NOT "${LIBUSB_LIBRARIES}" STREQUAL "")
458         set (GAMMU_LIBS "${GAMMU_LIBS} -l${LIBUSB_LIBRARIES}")
459     endif (NOT "${LIBUSB_LIBRARIES}" STREQUAL "")
460 endif (LIBUSB_FOUND)
462 set (SMSD_LIBS "")
464 if (MYSQL_FOUND)
465     if (NOT "${MYSQL_LIBRARIES}" STREQUAL "")
466         set (SMSD_LIBS "${SMSD_LIBS} -l${MYSQL_LIBRARIES}")
467     endif (NOT "${MYSQL_LIBRARIES}" STREQUAL "")
468 endif (MYSQL_FOUND)
470 if (POSTGRES_FOUND)
471     if (NOT "${POSTGRES_LIBRARY}" STREQUAL "")
472         set (SMSD_LIBS "${SMSD_LIBS} -l${POSTGRES_LIBRARY}")
473     endif (NOT "${POSTGRES_LIBRARY}" STREQUAL "")
474 endif (POSTGRES_FOUND)
476 # Tweak compiler flags
477 if(MSVC)
478     # MSVC needs different flags at all
479     MACRO_TUNE_COMPILER("/W3")
480 endif(MSVC)
482 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_MINGW OR
483     CMAKE_COMPILER_IS_CYGWIN OR CMAKE_COMPILER_IS_GNUCXX OR CLANG_COMPILER)
484     # Check for extra compiler flags we want to use
485     if (NOT GAMMU_VERSION_PATCH LESS 90)
486         MACRO_TUNE_COMPILER("-Werror")
487     endif (NOT GAMMU_VERSION_PATCH LESS 90)
489     #
490     # Warnings related flags
491     #
492     MACRO_TUNE_COMPILER("-Wall")
493     MACRO_TUNE_COMPILER("-Werror-implicit-function-declaration")
494     MACRO_TUNE_COMPILER("-Wno-deprecated-declarations")
495     MACRO_TUNE_COMPILER("-Wdeclaration-after-statement")
496     MACRO_TUNE_COMPILER("-Wpointer-arith")
497     MACRO_TUNE_COMPILER("-Wfloat-equal")
498     MACRO_TUNE_COMPILER("-Wbad-function-cast")
499     MACRO_TUNE_COMPILER("-Wmissing-format-attribute")
500     MACRO_TUNE_COMPILER("-Wmissing-noreturn")
501 #   This should be enabled and only public functions exported, but it is far future
502 #    MACRO_TUNE_COMPILER("-Wmissing-prototypes")
503     MACRO_TUNE_COMPILER("-Wpointer-arith")
504     MACRO_TUNE_COMPILER("-Wshadow")
505     MACRO_TUNE_COMPILER("-Wstrict-prototypes")
506     MACRO_TUNE_COMPILER("-Wsign-compare")
507 #   We need some typecasting (especially for iconv)
508 #    MACRO_TUNE_COMPILER("-Wcast-qual")
510     # Does not work well
511     #MACRO_TUNE_COMPILER("-Wunreachable-code")
513     # Just silent this for now, too much code to fix here
514     MACRO_TUNE_COMPILER("-Wno-pointer-sign")
516     # Check format strings
517     MACRO_TUNE_COMPILER("-Wshadow")
518     MACRO_TUNE_COMPILER("-Wformat=2")
519     MACRO_TUNE_COMPILER("-Wno-format-y2k")
520     MACRO_TUNE_COMPILER("-Wno-format-nonliteral")
521     # Win32 implementation of gettext does not allow us to use so strict warnings
522     if (WIN32 AND NOT CYGWIN)
523         MACRO_TUNE_COMPILER("-Wno-format-nonliteral")
524         MACRO_TUNE_COMPILER("-Wno-format-security")
525     endif (WIN32 AND NOT CYGWIN)
527     # Enable coverage if requested
528     if (NOT CLANG_COMPILER)
529         if (COVERAGE)
530             MACRO_TUNE_COMPILER_LINKER("-fprofile-arcs -ftest-coverage")
531         endif (COVERAGE)
532     endif (NOT CLANG_COMPILER)
534     # This is extremely noisy, use only in debug builds
535     if (DEBUG)
536         MACRO_TUNE_COMPILER("-Wextra")
537         if (NOT CLANG_COMPILER)
538             MACRO_TUNE_COMPILER("-Wunused-but-set-variable")
539         endif (NOT CLANG_COMPILER)
540         # Just silent this for now, too much code to fix here
541         MACRO_TUNE_COMPILER("-Wno-unused-parameter")
542         # Not sure if this is safe for all architectures
543     endif (DEBUG)
545     #
546     # Security related flags
547     #
548     if (NOT CLANG_COMPILER)
549         set (ENABLE_PROTECTION ON CACHE BOOL "Enable compile time protections (stack, read only code, fortify in libc...)")
550     endif (NOT CLANG_COMPILER)
551     if (ENABLE_PROTECTION)
552         # Need to enable -O to make fortify work
553         set (CMAKE_C_FLAGS_DEBUG "-g -O")
554         add_definitions(-D_FORTIFY_SOURCE=2)
556         # Text address randomisation, disabled for now, seems to cause problems
557         #    MACRO_TUNE_COMPILER("-fPIE")
558         #    MACRO_TUNE_LINKER("-pie")
559         # These do not work on Windows right now
560         if (NOT WIN32)
561             # Stack protector
562             MACRO_TUNE_COMPILER("-fstack-protector")
563             # Mark code read only
564             MACRO_TUNE_LINKER("-Wl,-zrelro")
565         endif (NOT WIN32)
566     endif (ENABLE_PROTECTION)
568     #
569     # Other flags
570     #
572     if (WIN32 AND NOT CYGWIN AND BUILD_SHARED_LIBS)
573         MACRO_TUNE_LINKER("-Wl,--enable-auto-import")
574     endif (WIN32 AND NOT CYGWIN AND BUILD_SHARED_LIBS)
576     MACRO_TUNE_LINKER("-Wl,--as-needed")
577     if (NOT WIN32)
578         set (PIC ON CACHE BOOL "Compile PIC code")
579         if (PIC)
580             MACRO_TUNE_COMPILER("-fPIC")
581         endif (PIC)
582     endif (NOT WIN32)
583     # Specs for MinGW to change msvcrt
584     # This is not supported by MinGW and is broken currently
585 #    if (CMAKE_COMPILER_IS_MINGW)
586 #        MACRO_TUNE_COMPILER("-specs=${CMAKE_CURRENT_SOURCE_DIR}/cmake/mingw.spec")
587 #        add_definitions(-D_MSVCRT_VERSION__=0x090)
588 #    endif (CMAKE_COMPILER_IS_MINGW)
589 endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_MINGW OR
590     CMAKE_COMPILER_IS_CYGWIN OR CMAKE_COMPILER_IS_GNUCXX OR CLANG_COMPILER)
592 if(BORLAND)
593     # Borland
594     # Suggests parenthesis
595     MACRO_TUNE_COMPILER("-wprc")
596     # Do not warn about unused params
597     MACRO_TUNE_COMPILER("-w-par")
598     # Warn about unused vars
599     MACRO_TUNE_COMPILER("-wuse")
600 endif(BORLAND)
603 # Define required libraries for gammu library if it is static
604 if (BUILD_SHARED_LIBS)
605     set (GAMMU_PRIVATE_LIBS "" CACHE INTERNAL "Private libraries for gammu library")
606     set (SMSD_PRIVATE_LIBS "" CACHE INTERNAL "Private libraries for gammu smsd library")
607 else (BUILD_SHARED_LIBS)
608     string(REGEX REPLACE "-l(/usr)?(/local)?/lib(64)?/lib([^ ]*).so" "-l\\4" G_LIB "${GAMMU_LIBS}")
609     string(REGEX REPLACE "-l(/usr)?(/local)?/lib(64)?/lib([^ ]*).so" "-l\\4" S_LIB "${SMSD_LIBS}")
610     set (GAMMU_PRIVATE_LIBS "${G_LIB}" CACHE INTERNAL "Private libraries for gammu library")
611     set (SMSD_PRIVATE_LIBS "${S_LIB}" CACHE INTERNAL "Private libraries for gammu smsd library")
612 endif (BUILD_SHARED_LIBS)
614 set (DOCS
615     README
616     ChangeLog
617     COPYING
618     )
620 # OpenCellID API key
621 set (OPENCELLID_API_KEY "2623b0e70e9fa77754a3db53f3cb6458" CACHE STRING "OpenCellID API key")
622 mark_as_advanced (OPENCELLID_API_KEY)
624 if (CMAKE_USE_PTHREADS_INIT)
625     set (HAVE_PTHREAD ON)
626 endif (CMAKE_USE_PTHREADS_INIT)
628 if (UNIX)
629     find_library (MATH_LIBRARIES m)
631     # Install paths
632     if ("${MATH_LIBRARIES}" MATCHES "/lib64/")
633         set (LIB_SUFFIX "64" CACHE STRING "Suffix of library directory (usually 64 or empty)")
634     else ("${MATH_LIBRARIES}" MATCHES "/lib64/")
635         set (LIB_SUFFIX "" CACHE STRING "Suffix of library directory (usually 64 or empty)")
636     endif ("${MATH_LIBRARIES}" MATCHES "/lib64/")
637 endif (UNIX)
640 set (INSTALL_BIN_DIR "bin" CACHE STRING "Path for binaries installation")
641 mark_as_advanced (INSTALL_BIN_DIR)
643 set (INSTALL_LIB_DIR "lib${LIB_SUFFIX}" CACHE STRING "Path for libraries installation")
644 mark_as_advanced (INSTALL_LIB_DIR)
646 set (INSTALL_LIBDATA_DIR "lib${LIB_SUFFIX}" CACHE STRING "Path for libraries data (eg. pkgconfig data) installation")
647 mark_as_advanced (INSTALL_LIBDATA_DIR)
649 set (INSTALL_INC_DIR "include/gammu" CACHE STRING "Path for includes installation")
650 mark_as_advanced (INSTALL_INC_DIR)
652 set (INSTALL_LOC_DIR "share/locale" CACHE STRING "Path for locales installation")
653 mark_as_advanced (INSTALL_LOC_DIR)
655 set (INSTALL_DATA_DIR "share/gammu" CACHE STRING "Path for data installation")
656 mark_as_advanced (INSTALL_DATA_DIR)
658 set (INSTALL_DOC_DIR "share/doc/gammu" CACHE STRING "Path for documentation installation")
659 mark_as_advanced (INSTALL_DOC_DIR)
661 set (INSTALL_MAN_DIR "share/man" CACHE STRING "Path for man pages installation")
662 mark_as_advanced (INSTALL_MAN_DIR)
664 # Phone and protocol configuration
666 # Nokia phones
667 macro_gammu_option (NOKIA_SUPPORT "Nokia support" ON ON ON)
669 macro_gammu_option (MBUS2 "Nokia MBUS2 protocol" ON WITH_NOKIA_SUPPORT ON)
670 macro_gammu_option (FBUS2 "Nokia FBUS2 protocol" ON WITH_NOKIA_SUPPORT ON)
671 macro_gammu_option (FBUS2DLR3 "Nokia FBUS2DLR3 protocol" ON WITH_NOKIA_SUPPORT ON)
672 macro_gammu_option (DKU2PHONET "Nokia DKU2PHONET protocol" ON WITH_NOKIA_SUPPORT ON)
673 macro_gammu_option (DKU2AT "Nokia DKU2AT protocol" ON WITH_NOKIA_SUPPORT ON)
674 macro_gammu_option (DKU5FBUS2 "Nokia DKU5FBUS2 protocol" ON WITH_NOKIA_SUPPORT ON)
675 macro_gammu_option (FBUS2PL2303 "Nokia FBUS2PL2303 protocol" ON WITH_NOKIA_SUPPORT ON)
677 macro_gammu_option (FBUS2BLUE "Nokia FBUS2BLUE protocol" ON WITH_NOKIA_SUPPORT BLUETOOTH_FOUND)
678 macro_gammu_option (PHONETBLUE "Nokia PHONETBLUE protocol" ON WITH_NOKIA_SUPPORT BLUETOOTH_FOUND)
679 macro_gammu_option (BLUEFBUS2 "Nokia BLUEFBUS2 protocol" ON WITH_NOKIA_SUPPORT BLUETOOTH_FOUND)
680 macro_gammu_option (BLUEPHONET "Nokia BLUEPHONET protocol" ON WITH_NOKIA_SUPPORT BLUETOOTH_FOUND)
682 macro_gammu_option (IRDAPHONET "Nokia IRDAPHONET protocol" ON WITH_NOKIA_SUPPORT IRDA_FOUND)
683 macro_gammu_option (FBUS2IRDA "Nokia FBUS2IRDA protocol" ON WITH_NOKIA_SUPPORT IRDA_FOUND)
685 macro_gammu_option (NOKIA3320 "Nokia 3320 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
686 macro_gammu_option (NOKIA650 "Nokia 650 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
687 macro_gammu_option (NOKIA6110 "Nokia 61xx and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
688 macro_gammu_option (NOKIA6510 "Nokia 6510 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
689 macro_gammu_option (DCT4_CALENDAR_6210 "Force using 6210 frames for calendar for DCT4 phones" OFF WITH_NOKIA_SUPPORT WITH_NOKIA6510)
690 if (WITH_DCT4_CALENDAR_6210)
691     set (GSM_FORCE_DCT4_CALENDAR_6210 TRUE)
692 endif (WITH_DCT4_CALENDAR_6210)
693 macro_gammu_option (NOKIA7110 "Nokia 7110 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
694 macro_gammu_option (NOKIA9210 "Nokia 9210 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
695 if (WITH_NOKIA7110 OR WITH_NOKIA9210)
696     set (wITH_71_92 ON)
697 else (WITH_NOKIA7110 OR WITH_NOKIA9210)
698     set (wITH_71_92)
699 endif (WITH_NOKIA7110 OR WITH_NOKIA9210)
700 macro_gammu_option (N71_92INCOMINGINFO "Nokia 62xx/71xx/9xxx incoming call/SMS info" OFF WITH_NOKIA_SUPPORT WITH_71_92)
701 macro_gammu_option (NOKIA3650 "Nokia 3650 and compatible phones support" ON WITH_NOKIA_SUPPORT ON)
703 # AT phones
704 macro_gammu_option (AT_SUPPORT "AT support" ON ON ON)
706 macro_gammu_option (AT "AT protocol" ON WITH_AT_SUPPORT ON)
707 macro_gammu_option (BLUEAT "AT protocol over Bluetooth" ON WITH_AT_SUPPORT BLUETOOTH_FOUND)
708 macro_gammu_option (IRDAAT "AT protocol over IrDA" ON WITH_AT_SUPPORT IRDA_FOUND)
710 macro_gammu_option (ATGEN "AT phones support" ON WITH_AT_SUPPORT ON)
712 macro_gammu_option (ALCATEL_SUPPORT "Alcatel support" ON WITH_AT_SUPPORT ON)
714 macro_gammu_option (ALCABUS "Alcatel protocol" ON WITH_ALCATEL_SUPPORT ON)
716 macro_gammu_option (ALCATEL "Alcatel phones support" ON WITH_ALCATEL_SUPPORT ON)
718 # OBEX phones
719 macro_gammu_option (OBEX_SUPPORT "OBEX compatible phones support" ON ON ON)
721 macro_gammu_option (BLUEOBEX "OBEX protocol over Bluetooth" ON WITH_OBEX_SUPPORT BLUETOOTH_FOUND)
722 macro_gammu_option (IRDAOBEX "OBEX protocol over IrDA" ON WITH_OBEX_SUPPORT IRDA_FOUND)
724 macro_gammu_option (OBEXGEN "Generic OBEX phones support" ON WITH_OBEX_SUPPORT ON)
725 macro_gammu_option (ATOBEX "AT with OBEX phones support" ON WITH_OBEX_SUPPORT WITH_AT_SUPPORT)
726 macro_gammu_option (ATOBEX_AUTO_MODE "Automatic switching to OBEX for AT+MODE capable phones" OFF WITH_ATOBEX_SUPPORT ON)
728 macro_gammu_option (S60_SUPPORT "Symbian phones support (S60)" ON ON ON)
729 macro_gammu_option (GNAPPLET_SUPPORT "Symbian phones support (gnapplet)" ON WITH_NOKIA_SUPPORT ON)
730 macro_gammu_option (BLUEGNAPBUS "GNAPBUS protocol over Bluetooth" ON WITH_GNAPPLET_SUPPORT BLUETOOTH_FOUND)
731 macro_gammu_option (IRDAGNAPBUS "GNAPBUS protocol over IrDA" ON WITH_GNAPPLET_SUPPORT IRDA_FOUND)
733 macro_gammu_option (GNAPGEN "Gnapplet phones support" ON WITH_GNAPPLET_SUPPORT ON)
735 macro_gammu_option (S60 "S60 phones support" ON WITH_S60_SUPPORT ON)
737 # Some generic configurations
738 macro_gammu_option (CELLBROADCAST "Cell Broadcast messages support" ON ON ON)
739 macro_gammu_option (BACKUP "Backup/Restore functions" ON ON ON)
741 # Generate Doxygen file
742 set (DOXYGEN_INPUT "${CMAKE_CURRENT_BINARY_DIR}/include")
743 set (DOXYGEN_INTERNAL_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/libgammu")
744 set (DOXYGEN_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gammu-doc")
745 set (DOXYGEN_INTERNAL_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gammu-internal-doc")
746 if ("${DOXYGEN_DOT_EXECUTABLE}" STREQUAL DOXYGEN_DOT_EXECUTABLE-NOTFOUND)
747     set (HAVE_DOT "NO")
748     set (DOXYGEN_DOT_PATH "")
749 else ("${DOXYGEN_DOT_EXECUTABLE}" STREQUAL DOXYGEN_DOT_EXECUTABLE-NOTFOUND)
750     set (HAVE_DOT "YES")
751     # Strip binary name from variable
752     string (REGEX REPLACE "/dot$" "" DOXYGEN_DOT_PATH "${DOXYGEN_DOT_EXECUTABLE}")
753 endif ("${DOXYGEN_DOT_EXECUTABLE}" STREQUAL DOXYGEN_DOT_EXECUTABLE-NOTFOUND)
754 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/Doxyfile.cmake" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/Doxyfile")
755 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/Doxyfile-internal.cmake" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/Doxyfile-internal")
756 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/api.desc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/api.desc")
757 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/internals.desc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/internals.desc")
759 # Target for generating API documentation
760 add_custom_target (apidoc ${DOXYGEN_EXECUTABLE} doxygen/Doxyfile
761     COMMAND find ${DOXYGEN_OUTPUT}/html -name '*.html' -print0 | xargs -0 sed -i 's@text/html\;charset=iso-8859-1@text/html\;charset=utf-8@'
762     COMMENT "Generating API documentation")
764 add_custom_target (interndoc ${DOXYGEN_EXECUTABLE} doxygen/Doxyfile-internal
765     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@'
766     COMMENT "Generating internal documentation")
768 # CPP check
769 find_program(CPPCHECK_EXECUTABLE NAMES cppcheck
770     DOC "cppcheck - code checking tool")
771 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"
772     COMMENT "Checking C code")
775 # Generate pkgconfig file
776 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gammu.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cfg/gammu.pc" @ONLY)
777 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gammu-smsd.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cfg/gammu-smsd.pc" @ONLY)
778 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gammu-uninstalled.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/gammu.pc" @ONLY)
779 configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gammu-smsd-uninstalled.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/gammu-smsd.pc" @ONLY)
781 # Install instructions
783 # Install Windows libraries
784 if (WIN32 AND NOT CYGWIN)
785     # MySQL
786     if (MYSQL_FOUND)
787         foreach(lib ${WIN_LIB_MYSQL})
788             ADD_DLL("${lib}" "${MYSQL_LIBRARIES}")
789         endforeach(lib ${WIN_LIB_MYSQL})
790     endif (MYSQL_FOUND)
792     # PostgreSQL and dependencies
793     if (POSTGRES_FOUND)
794         foreach(lib ${WIN_LIB_PGSQL})
795             ADD_DLL("${lib}" "${POSTGRES_LIBRARY}")
796         endforeach(lib ${WIN_LIB_PGSQL})
797     endif (POSTGRES_FOUND)
799     # iconv and dependencies
800     if (ICONV_FOUND)
801         foreach(lib ${WIN_LIB_ICONV})
802             ADD_DLL("${lib}" "${ICONV_LIBRARIES}")
803         endforeach(lib ${WIN_LIB_ICONV})
804     endif (ICONV_FOUND)
806     # Gettext and dependencies
807     if (LIBINTL_LIB_FOUND)
808         foreach(lib ${WIN_LIB_INTL})
809             ADD_DLL("${lib}" "${LIBINTL_LIBRARY}")
810         endforeach(lib ${WIN_LIB_INTL})
811     endif (LIBINTL_LIB_FOUND)
813     # Curl and dependencies
814     if (CURL_FOUND)
815         foreach(lib ${WIN_LIB_CURL})
816             ADD_DLL("${lib}" "${CURL_LIBRARIES}")
817         endforeach(lib ${WIN_LIB_CURL})
818     endif (CURL_FOUND)
820     # Glib and dependencies
821     if (GLIB_FOUND)
822         foreach(lib ${WIN_LIB_GLIB})
823             ADD_DLL("${lib}" "${GLIB_LIBRARIES}")
824         endforeach(lib ${WIN_LIB_GLIB})
825     endif (GLIB_FOUND)
827     install (FILES ${WIN32_INSTALL_DLL}
828             DESTINATION "${INSTALL_BIN_DIR}"
829             COMPONENT dlls
830             )
831 endif (WIN32 AND NOT CYGWIN)
833 install (
834     FILES "${CMAKE_CURRENT_BINARY_DIR}/cfg/gammu.pc" "${CMAKE_CURRENT_BINARY_DIR}/cfg/gammu-smsd.pc"
835     DESTINATION "${INSTALL_LIBDATA_DIR}/pkgconfig"
836     COMPONENT "pkgconfig"
837     )
839 # We want some tests. Even when cross compiling for Windows tests can be
840 # done in Wine. This is better than nothing, even though Wine is a bit
841 # more fault tolerant when linking DLLs.
843 # Valgrind supressions for python
844 set (MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/valgrind-python.supp CACHE FILEPATH "File that contains suppressions for the memory checker")
846 # Testing and dashboard
847 include(CTest)
848 enable_testing()
849 include(Dart)
851 # Packaging support
852 set (CPACK_PACKAGE_NAME "Gammu")
853 set (CPACK_PACKAGE_VERSION "${GAMMU_VERSION}")
854 set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gammu All Mobile Management Utilities ${GAMMU_VERSION}")
855 set (CPACK_PACKAGE_VENDOR "Michal Čihař")
856 set (CPACK_PACKAGE_CONTACT "Michal Čihař <michal@cihar.com>")
857 set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/installer/description.txt")
858 # On Mac OS, the file needs .txt extension, give it to them
859 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/readme.txt" COPYONLY)
860 set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_BINARY_DIR}/readme.txt")
861 set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/installer/license.txt")
862 set (CPACK_PACKAGE_VERSION_MAJOR "${GAMMU_VERSION_MAJOR}")
863 set (CPACK_PACKAGE_VERSION_MINOR "${GAMMU_VERSION_MINOR}")
864 set (CPACK_PACKAGE_VERSION_PATCH "${GAMMU_VERSION_PATCH}")
865 set (CPACK_INSTALLER_PROGRAM_DISK_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/installer/addpostflight")
867 if (WIN32 AND NOT CYGWIN)
868     set (CPACK_SYSTEM_NAME "Windows" CACHE STRING "Windows package name")
869 endif (WIN32 AND NOT CYGWIN)
871 # RPM
872 set (CPACK_RPM_PACKAGE_LICENSE "GPLv2")
873 if (EXISTS "/etc/SuSE-release")
874 set (CPACK_RPM_PACKAGE_GROUP "Hardware/Mobile")
875 else (EXISTS "/etc/SuSE-release")
876 set (CPACK_RPM_PACKAGE_GROUP "Applications/Communications")
877 endif (EXISTS "/etc/SuSE-release")
879 # Components
880 set (CPACK_COMPONENTS_ALL gammu library smsd headers utils manpages docs pkgconfig symbian examples manual)
881 if (WITH_PYTHON)
882     list (APPEND CPACK_COMPONENTS_ALL python)
883 endif (WITH_PYTHON)
884 if (WIN32 AND NOT CYGWIN AND WIN32_INSTALL_DLL)
885     list (APPEND CPACK_COMPONENTS_ALL dlls)
886 endif (WIN32 AND NOT CYGWIN AND WIN32_INSTALL_DLL)
888 set (CPACK_COMPONENT_GAMMU_DISPLAY_NAME "Gammu Application")
889 set (CPACK_COMPONENT_SMSD_DISPLAY_NAME "Gammu SMS Daemon")
890 set (CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Gammu Library")
891 set (CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C Headers")
892 set (CPACK_COMPONENT_UTILS_DISPLAY_NAME "Utility Scripts")
893 set (CPACK_COMPONENT_MANPAGES_DISPLAY_NAME "Manual Pages")
894 set (CPACK_COMPONENT_DOCS_DISPLAY_NAME "User Documentation")
895 set (CPACK_COMPONENT_PKGCONFIG_DISPLAY_NAME "Pkg-config Data")
896 set (CPACK_COMPONENT_SYMBIAN_DISPLAY_NAME "Applet for Symbian Phones")
897 set (CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Examples Using Gammu")
898 set (CPACK_COMPONENT_MANUAL_DISPLAY_NAME "Gammu Manual")
899 set (CPACK_COMPONENT_PYTHON_DISPLAY_NAME "Python Module")
900 set (CPACK_COMPONENT_MEDIA_DISPLAY_NAME "Media Files")
902 set (CPACK_COMPONENT_DLLS_HIDDEN TRUE)
903 set (CPACK_COMPONENT_DLLS_REQUIRED TRUE)
904 set (CPACK_COMPONENT_LIBRARY_REQUIRED TRUE)
906 set (CPACK_COMPONENT_GAMMU_DESCRIPTION "The gammu.exe program.")
907 set (CPACK_COMPONENT_SMSD_DESCRIPTION "Gammu SMS Daemon which automatically sends and receives messages.")
908 set (CPACK_COMPONENT_LIBRARY_DESCRIPTION "Gammu library.")
909 set (CPACK_COMPONENT_HEADERS_DESCRIPTION "C headers for development own programs using Gammu library.")
910 set (CPACK_COMPONENT_UTILS_DESCRIPTION "Utility scripts, mostly written using bourne shell, which you need to install on your own.")
911 set (CPACK_COMPONENT_MANPAGES_DESCRIPTION "Manual pages for programs and configuration files.")
912 set (CPACK_COMPONENT_DOCS_DESCRIPTION "User documentation in text files.")
913 set (CPACK_COMPONENT_PKGCONFIG_DESCRIPTION "Data for pkg-config program (automatic finding of compiler parameters for libraries).")
914 set (CPACK_COMPONENT_SYMBIAN_DESCRIPTION "Applet for Symbian phones, install it to phone to communicate with them using Gammu.")
915 set (CPACK_COMPONENT_EXAMPLES_DESCRIPTION "Examples showing how to use Gammu, in PHP, Perl or C.")
916 set (CPACK_COMPONENT_MANUAL_DESCRIPTION "User and Developer Manual")
917 set (CPACK_COMPONENT_PYTHON_DESCRIPTION "Python module for Gammu.")
918 set (CPACK_COMPONENT_MEDIA_DESCRIPTION "Various media files which can be used with Gammu.")
920 set (CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "Programs and libraries for general usage.")
921 set (CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "Headers and documentation used for development using Gammu.")
922 set (CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION "Gammu documentation and usage examples.")
924 set(CPACK_COMPONENT_GAMMU_DEPENDS library)
925 if (WIN32 AND NOT CYGWIN AND WIN32_INSTALL_DLL)
926 set(CPACK_COMPONENT_LIBRARY_DEPENDS dlls)
927 endif (WIN32 AND NOT CYGWIN AND WIN32_INSTALL_DLL)
928 set(CPACK_COMPONENT_SMSD_DEPENDS library)
929 set(CPACK_COMPONENT_HEADERS_DEPENDS library)
930 set(CPACK_COMPONENT_PYTHON_DEPENDS library)
931 set(CPACK_COMPONENT_UTILS_DEPENDS gammu)
932 set(CPACK_COMPONENT_PKGCONFIG_DEPENDS headers)
934 set (CPACK_COMPONENT_GAMMU_GROUP "Runtime")
935 set (CPACK_COMPONENT_SMSD_GROUP "Runtime")
936 set (CPACK_COMPONENT_UTILS_GROUP "Runtime")
937 set (CPACK_COMPONENT_LIBRARY_GROUP "Runtime")
938 set (CPACK_COMPONENT_PYTHON_GROUP "Runtime")
940 set (CPACK_COMPONENT_HEADERS_GROUP "Development")
941 set (CPACK_COMPONENT_PKGCONFIG_GROUP "Development")
943 set (CPACK_COMPONENT_MANPAGES_GROUP "Documentation")
944 set (CPACK_COMPONENT_DOCS_GROUP "Documentation")
945 set (CPACK_COMPONENT_EXAMPLES_GROUP "Documentation")
946 set (CPACK_COMPONENT_MANUAL_GROUP "Documentation")
947 set (CPACK_COMPONENT_MEDIA_GROUP "Documentation")
949 set (CPACK_ALL_INSTALL_TYPES Standard Developer Full)
951 set (CPACK_COMPONENT_GAMMU_INSTALL_TYPES Standard Developer Full)
952 set (CPACK_COMPONENT_SMSD_INSTALL_TYPES Standard Developer Full)
953 set (CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Standard Developer Full)
954 set (CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
955 set (CPACK_COMPONENT_UTILS_INSTALL_TYPES Full)
956 set (CPACK_COMPONENT_MANPAGES_INSTALL_TYPES Standard Developer Full)
957 set (CPACK_COMPONENT_DOCS_INSTALL_TYPES Standard Developer Full)
958 set (CPACK_COMPONENT_PKGCONFIG_INSTALL_TYPES Developer Full)
959 set (CPACK_COMPONENT_SYMBIAN_INSTALL_TYPES Standard Developer Full)
960 set (CPACK_COMPONENT_EXAMPLES_INSTALL_TYPES Developer Full)
961 set (CPACK_COMPONENT_MANUAL_INSTALL_TYPES Developer Full)
962 set (CPACK_COMPONENT_PYTHON_INSTALL_TYPES Developer Full)
963 set (CPACK_COMPONENT_MEDIA_INSTALL_TYPES Full)
965 if (WIN32 AND NOT CYGWIN)
966   set (CPACK_PACKAGE_INSTALL_DIRECTORY "Gammu ${GAMMU_VERSION}")
967   set (CPACK_NSIS_DISPLAY_NAME "Gammu ${GAMMU_VERSION}")
968   set (CPACK_NSIS_HELP_LINK "http://wammu.eu/support/")
969   set (CPACK_NSIS_URL_INFO_ABOUT "http://wammu.eu/gammu/")
970   set (CPACK_NSIS_CONTACT "michal@cihar.com")
971   set (CPACK_NSIS_MODIFY_PATH ON)
972   SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
973                     ExecWait  \\\"$INSTDIR\\\\bin\\\\gammu-smsd.exe -e \\\"
974             ")
975   SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
976                     ExecWait  \\\"$INSTDIR\\\\bin\\\\gammu-smsd.exe -E \\\"
977             ")
978 else (WIN32 AND NOT CYGWIN)
979   set (CPACK_STRIP_FILES "gammu")
980   set (CPACK_SOURCE_STRIP_FILES "")
981 endif (WIN32 AND NOT CYGWIN)
982 include (CPack)
984 # Test files for Gammu
985 set (RINGTONE_TEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/media/axelf.txt)
986 set (LOGO_TEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/media/aliens.nlm)
988 # Transverse to dirs
989 add_subdirectory(include)
991 add_subdirectory(libgammu)
993 add_subdirectory(helper)
995 add_subdirectory(tests)
997 add_subdirectory(smsd)
999 add_subdirectory(gammu)
1001 add_subdirectory(gammu-detect)
1003 add_subdirectory(locale)
1005 add_subdirectory(utils)
1007 option(INSTALL_DOC "Install documentation" ON)
1009 if(INSTALL_DOC)
1010     install (
1011         FILES ${DOCS}
1012         DESTINATION "${INSTALL_DOC_DIR}"
1013         COMPONENT "docs"
1014         )
1016     add_subdirectory(docs/config)
1017     add_subdirectory(docs/manual)
1018     add_subdirectory(docs/examples)
1019     add_subdirectory(docs/sql)
1020     add_subdirectory(docs/man)
1021 endif(INSTALL_DOC)
1023 add_subdirectory(contrib)
1025 if (WITH_PYTHON)
1026     add_subdirectory(python)
1027 else (WITH_PYTHON)
1028     message ("Python bindings are disabled!")
1029 endif (WITH_PYTHON)