"Fossies" - the Fresh Open Source Software Archive

Member "gammu-1.42.0/CMakeLists.txt" (3 Oct 2020, 37012 Bytes) of package /linux/privat/gammu-1.42.0.tar.bz2:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 1.41.0_vs_1.42.0.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


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