Translation update done using Pootle.
[gammu.git] / smsd / CMakeLists.txt
blob8ec4b268b330f6434fcac1d7b5536e6d7c5d46c6
1 # cmake <http://www.cmake.org> build file for Gammu
2 # Copyright © 2007 - 2009 Michal Čihař
3 # vim: expandtab sw=4 ts=4 sts=4:
5 project (gammu-smsd C)
7 include(GammuTuneCompiler)
9 set (LIBRARY_SRC
10     core.c
11     services/files.c
12     services/null.c
13     )
15 if (HAVE_MYSQL_MYSQL_H OR LIBDBI_FOUND OR HAVE_POSTGRESQL_LIBPQ_FE_H OR ODBC_FOUND)
16     list(APPEND LIBRARY_SRC services/sql.c)
17 endif (HAVE_MYSQL_MYSQL_H OR LIBDBI_FOUND OR HAVE_POSTGRESQL_LIBPQ_FE_H OR ODBC_FOUND)
19 if (HAVE_MYSQL_MYSQL_H)
20     list(APPEND LIBRARY_SRC services/mysql.c)
21 endif (HAVE_MYSQL_MYSQL_H)
23 if (HAVE_POSTGRESQL_LIBPQ_FE_H)
24     list(APPEND LIBRARY_SRC services/pgsql.c)
25 endif (HAVE_POSTGRESQL_LIBPQ_FE_H)
27 if (LIBDBI_FOUND)
28     list(APPEND LIBRARY_SRC services/dbi.c)
29 endif (LIBDBI_FOUND)
31 if (ODBC_FOUND)
32     list(APPEND LIBRARY_SRC services/odbc.c)
33 endif (ODBC_FOUND)
35 if (WIN32)
36     list(APPEND LIBRARY_SRC log-event.c)
37 endif (WIN32)
39 set (DAEMON_SRC
40     main.c
41     )
43 if (WIN32)
44     list(APPEND DAEMON_SRC winservice.c)
45 endif (WIN32)
47 if (HAVE_KILL)
48     list(APPEND DAEMON_SRC pidfile.c)
49 endif (HAVE_KILL)
51 if (HAVE_GETPWNAM OR HAVE_GETGRNAM OR HAVE_SETUID OR HAVE_SETGID)
52     list(APPEND DAEMON_SRC uid.c)
53 endif (HAVE_GETPWNAM OR HAVE_GETGRNAM OR HAVE_SETUID OR HAVE_SETGID)
55 set (INJECT_SRC
56     inject.c
57     )
59 set (MONITOR_SRC
60     monitor.c
61     )
63 # Hides default case in switch, to allow checking whether all cases are handled.
64 if(DEBUG)
65     add_definitions(-DCHECK_CASES)
66 endif(DEBUG)
68 # SMSD library
69 add_library (gsmsd ${LIBRARY_SRC})
70 set_target_properties (gsmsd PROPERTIES
71     VERSION ${GAMMU_SOVERSION}.${GAMMU_VERSION}
72     SOVERSION ${GAMMU_SOVERSION})
73 if (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_COMPILER_IS_MINGW AND NOT CMAKE_COMPILER_IS_CYGWIN)
74     set_target_properties (gsmsd PROPERTIES COMPILE_FLAGS -fPIC)
75 endif (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_COMPILER_IS_MINGW AND NOT CMAKE_COMPILER_IS_CYGWIN)
76 if(CMAKE_COMPILER_IS_MINGW AND BUILD_SHARED_LIBS)
77     SET_TARGET_PROPERTIES(gsmsd PROPERTIES LINK_FLAGS
78         "-Wl,--output-def,${CMAKE_CURRENT_BINARY_DIR}/libgsmsd.def")
79     INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgsmsd.def
80             DESTINATION "${INSTALL_LIB_DIR}"
81             COMPONENT smsd)
82 endif(CMAKE_COMPILER_IS_MINGW AND BUILD_SHARED_LIBS)
84 target_link_libraries (gsmsd libGammu)
85 if (NOT HAVE_STRPTIME)
86     target_link_libraries (gsmsd strptime)
87 endif (NOT HAVE_STRPTIME)
88 target_link_libraries (gsmsd array)
90 # Gammu-smsd program
91 add_executable (gammu-smsd ${DAEMON_SRC})
93 target_link_libraries (gammu-smsd libGammu)
94 target_link_libraries (gammu-smsd gsmsd)
96 # Gammu-smsd-inject program
97 add_executable (gammu-smsd-inject ${INJECT_SRC})
99 target_link_libraries (gammu-smsd-inject libGammu)
100 target_link_libraries (gammu-smsd-inject gsmsd)
101 target_link_libraries (gammu-smsd-inject messagecmdline)
103 if (HAVE_SHM OR WIN32)
104 # Gammu-smsd-monitor program
105     add_executable (gammu-smsd-monitor ${MONITOR_SRC})
107     target_link_libraries (gammu-smsd-monitor libGammu)
108     target_link_libraries (gammu-smsd-monitor gsmsd)
109 endif (HAVE_SHM OR WIN32)
111 include_directories (
112     "${CMAKE_CURRENT_BINARY_DIR}/../include"
113     )
115 # Tune options for found libraries
116 if (LIBDBI_FOUND)
117     target_link_libraries (gsmsd ${LIBDBI_LIBRARIES})
118     include_directories (${LIBDBI_INCLUDE_DIR})
119 endif (LIBDBI_FOUND)
121 if (ODBC_FOUND)
122     target_link_libraries (gsmsd ${ODBC_LIBRARIES})
123     include_directories (${ODBC_INCLUDE_DIR})
124 endif (ODBC_FOUND)
126 if (MYSQL_FOUND)
127     target_link_libraries (gsmsd ${MYSQL_LIBRARIES})
128     include_directories (${MYSQL_INCLUDE_DIR})
129 endif (MYSQL_FOUND)
131 if (POSTGRES_FOUND)
132     target_link_libraries (gsmsd ${POSTGRES_LIBRARY})
133     include_directories (${POSTGRES_INCLUDE_DIR})
134 endif (POSTGRES_FOUND)
136 install (TARGETS gsmsd gammu-smsd gammu-smsd-inject
137         RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
138         COMPONENT smsd
139         LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
140         COMPONENT smsd
141         ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
142         COMPONENT smsd
143         )
144 if (HAVE_SHM OR WIN32)
145     install (TARGETS gammu-smsd-monitor
146             RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
147             COMPONENT smsd
148             LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
149             COMPONENT smsd
150             ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
151             COMPONENT smsd
152             )
153 endif (HAVE_SHM OR WIN32)
155 # Testing
156 include(CMakeTests.txt)