Keep in sync with autotools.
[platform/upstream/dbus.git] / cmake / CMakeLists.txt
1 project(dbus)
2
3 set (DBUS_MAJOR_VERSION "1")
4 set (DBUS_MINOR_VERSION "4")
5 set (DBUS_MICRO_VERSION "3")
6 # used by file version info
7 set (DBUS_PATCH_VERSION "0")
8 set (DBUS_VERSION ${DBUS_MAJOR_VERSION}.${DBUS_MINOR_VERSION}.${DBUS_MICRO_VERSION})
9
10 set (DBUS_VERSION_STRING "${DBUS_VERSION}")
11
12 if (NOT DBUS_BUILD_TIMESTAMP)
13     message(STATUS "FIXME set DBUS_BUILD_TIMESTAMP to current date or fix current time stamp generation for having actual build date in version file info")
14     set (DBUS_BUILD_TIMESTAMP 20091231)
15 endif (NOT DBUS_BUILD_TIMESTAMP)
16
17 # we need to be up to date
18 CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
19 if(COMMAND cmake_policy)
20     cmake_policy(SET CMP0003 NEW)
21 endif(COMMAND cmake_policy)
22
23 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
24 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
25
26 ########### basic vars ###############
27
28
29 if (DBUSDIR)
30         set(DBUS_INSTALL_DIR "${DBUSDIR}")
31 endif (DBUSDIR)
32 if ($ENV{DBUSDIR})
33         set(DBUS_INSTALL_DIR "$ENV{DBUSDIR}")
34 endif ($ENV{DBUSDIR})
35
36 if (DBUS_INSTALL_DIR)
37         set(CMAKE_INSTALL_PREFIX "${DBUS_INSTALL_DIR}" CACHE TYPE PATH FORCE)
38 else (DBUS_INSTALL_DIR)
39         set(DBUS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
40 endif (DBUS_INSTALL_DIR)
41
42 # autotools style
43 if (NOT DATAROOTDIR)
44     set (DATAROOTDIR share)
45 endif()
46
47 if (NOT DATADIR)
48     set (DATADIR ${DATAROOTDIR})
49 endif()
50
51 if (NOT DOCDIR)
52     SET(DOCDIR ${DATAROOTDIR}/doc/dbus)
53 endif()
54
55 if (NOT DBUS_DATADIR)
56     SET(DBUS_DATADIR ${DATADIR})
57 endif()
58
59 set(prefix                   ${DBUS_INSTALL_DIR})
60 set(exec_prefix              ${prefix})
61 set(EXPANDED_LIBDIR          ${DBUS_INSTALL_DIR}/lib)
62 set(EXPANDED_INCLUDEDIR      ${DBUS_INSTALL_DIR}/include)
63 set(EXPANDED_BINDIR          ${DBUS_INSTALL_DIR}/bin)
64 set(EXPANDED_SYSCONFDIR      ${DBUS_INSTALL_DIR}/etc)
65 set(EXPANDED_DATADIR         ${DBUS_INSTALL_DIR}/${DBUS_DATADIR})
66 set(DBUS_MACHINE_UUID_FILE   ${DBUS_INSTALL_DIR}/lib/dbus/machine-id)
67 set(DBUS_BINDIR              ${EXPANDED_BINDIR})
68 set(DBUS_DAEMONDIR                       ${EXPANDED_BINDIR})
69
70
71 #enable building of shared library
72 SET(BUILD_SHARED_LIBS ON)
73
74 if (CYGWIN)
75    set (WIN32)
76 endif (CYGWIN)
77
78 # search for required packages
79 if (WIN32)
80     # include local header first to avoid using old installed header
81     set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/..)
82         find_package(LibIconv)
83     include(Win32Macros)
84     addExplorerWrapper(${CMAKE_PROJECT_NAME})
85 endif (WIN32)
86 find_package(LibXml2)
87 find_package(LibExpat)
88 find_package(X11)
89
90 if(NOT WIN32)
91         OPTION(DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON)
92 endif(NOT WIN32)
93
94 #AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE)
95 OPTION(DBUS_DISABLE_ASSERTS "Disable assertion checking" OFF)
96
97 # do config checks
98 INCLUDE(ConfigureChecks.cmake)
99
100 # @TODO: how to remove last dir from ${CMAKE_SOURCE_DIR} ?
101 SET(DBUS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/..)
102
103 # make some more macros available
104 include (MacroLibrary)
105
106 if(VCS)
107         set(DBUS_VERBOSE_C_S 1 CACHE TYPE STRING FORCE)
108         set(DBUS_VERBOSE_C_S 1)
109 endif(VCS)
110
111 if(WIN32)
112         set(CMAKE_DEBUG_POSTFIX "d")
113         if(MSVC)
114                 # controll folders in msvc projects
115                 include(ProjectSourceGroup)
116                 if(NOT GROUP_CODE)
117                         #set(GROUP_CODE split) #cmake default
118                         set(GROUP_CODE flat)
119                 endif(NOT GROUP_CODE)
120                 ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
121
122
123                 # Use the highest warning level
124                 if (WALL)
125                         set(WALL 1 CACHE TYPE STRING FORCE)
126                         set(CMAKE_CXX_WARNING_LEVEL 4 CACHE TYPE STRING FORCE)
127
128                         if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
129                                 STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
130                         else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
131                                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
132                         endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
133
134                         if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
135                                 STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
136                         else(CMAKE_C_FLAGS MATCHES "/W[0-4]")
137                                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
138                         endif(CMAKE_C_FLAGS MATCHES "/W[0-4]")
139                 else (WALL)
140                         set(CMAKE_CXX_WARNING_LEVEL 3 CACHE TYPE STRING FORCE)
141                 endif (WALL)
142
143                 SET(MSVC_W_ERROR   " /we4028 /we4013 /we4133 /we4047 /we4031 /we4002 /we4003 /we4114")
144                 SET(MSVC_W_DISABLE " /wd4127 /wd4090 /wd4101 /wd4244")
145
146                 SET(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG}   /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}")
147                 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}")
148         endif(MSVC)
149 endif(WIN32)
150
151 if (UNIX AND NOT DBUS_DISABLE_ASSERTS)
152         # required for backtrace
153         SET(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG}   -Wl,--export-dynamic")
154         SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wl,--export-dynamic")
155         add_definitions(-DDBUS_BUILT_R_DYNAMIC)
156 endif (UNIX AND NOT DBUS_DISABLE_ASSERTS)
157
158 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}  -D_DEBUG")
159
160 #########################################################################
161 # Windows CE (>= 5.0.0)
162 #
163 # WinCE support now relies on the presence of platform files, found in cmake/modules/platform
164 # Cmake 2.8.0 doesn't include WinCE platform files by default, but working ones can be found
165 # on CMake's bugtracker :
166 # http://public.kitware.com/Bug/view.php?id=7919
167 #
168 # for cmake 2.8.0 get the following patch only :
169 # http://public.kitware.com/Bug/file_download.php?file_id=2944&type=bug
170 #
171 # after applying the patch, you can enable the WinCE build by specifying :
172 # cmake [...] -DCMAKE_SYSTEM_NAME=WinCE -DCMAKE_SYSTEM_VERSION=X.XX
173 # (where X.XX is your actual WinCE version, e.g. 5.02 for Windows Mobile 6)
174 #
175 # Note that you should have a proper cross-compilation environment set up prior to running
176 # cmake, ie. the PATH, INCLUDE and LIB env vars pointing to your CE SDK/toolchain.
177 #
178 if(WINCE)
179
180 MESSAGE("Building for WinCE (${CMAKE_SYSTEM_VERSION})")
181
182 endif(WINCE)
183 #########################################################################
184
185
186 ENABLE_TESTING()
187
188 #########################################################################
189 # Disallow in-source build
190 #macro_ensure_out_of_source_build("dbus requires an out of source build. Please create a separate build directory and run 'cmake path_to_dbus [options]' there.")
191
192 # ... and warn in case of an earlier in-source build
193 #set(generatedFileInSourceDir EXISTS ${dbus_SOURCE_DIR}/config.h)
194 #if(${generatedFileInSourceDir})
195 #   message(STATUS "config.h exists in your source directory.")
196 #endif(${generatedFileInSourceDir})
197 #########################################################################
198
199 if (WIN32 OR CYGWIN)
200         set (LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/bin)
201 else (WIN32 OR CYGWIN)
202         set (LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
203 endif (WIN32 OR CYGWIN)
204
205 set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
206
207 # for including config.h and for includes like <dir/foo.h>
208 include_directories( ${CMAKE_SOURCE_DIR}/.. ${CMAKE_BINARY_DIR} ${CMAKE_INCLUDE_PATH} )
209
210 # linker search directories
211 link_directories(${DBUS_LIB_DIR} ${LIBRARY_OUTPUT_PATH} )
212 include_directories( ${CMAKE_LIBRARY_PATH}  )
213
214 set(DBUS_INCLUDES)
215
216 ENABLE_TESTING()
217
218 ########### command line options ###############
219 # TODO: take check from configure.in
220
221 #AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
222 OPTION(DBUS_BUILD_TESTS "enable unit test code" ON)
223  
224 if(DBUS_BUILD_TESTS)
225     add_definitions(-DDBUS_BUILD_TESTS)
226 endif(DBUS_BUILD_TESTS)
227
228 OPTION(DBUS_USE_OUTPUT_DEBUG_STRING "enable win32 debug port for message output" OFF)
229 if(DBUS_USE_OUTPUT_DEBUG_STRING)
230     add_definitions(-DDBUS_USE_OUTPUT_DEBUG_STRING)
231 endif(DBUS_USE_OUTPUT_DEBUG_STRING)
232
233 if(WIN32)
234         # win32 dbus service support - this support is not complete
235         OPTION(DBUS_SERVICE "enable dbus service installer" OFF)
236 endif(WIN32)
237
238 #AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no)
239 OPTION(DBUS_ENABLE_ANSI "enable -ansi -pedantic gcc flags" OFF)
240 if(DBUS_ENABLE_ANSI)
241    if(NOT MSVC)
242         add_definitions(-ansi -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -pedantic)
243    else(NOT MSVC)
244         add_definitions(-Za -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -W4)
245    endif(NOT MSVC)
246 endif(DBUS_ENABLE_ANSI)
247
248 #AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE)
249 OPTION(DBUS_ENABLE_VERBOSE_MODE "support verbose debug mode" ON)
250
251 #AC_ARG_ENABLE(checks, AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),enable_checks=$enableval,enable_checks=yes)
252 OPTION(DBUS_DISABLE_CHECKS "Disable public API sanity checking" OFF)
253
254 if(NOT MSVC)
255     #AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no)
256     OPTION(DBUS_GCOV_ENABLED "compile with coverage profiling instrumentation (gcc only)" OFF)
257     if(DBUS_GCOV_ENABLED)
258             add_definitions(-fprofile-arcs -ftest-coverage)
259             # FIXME!!!!
260             ## remove optimization
261     #        CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
262     endif(DBUS_GCOV_ENABLED)
263 endif(NOT MSVC)
264
265 #AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto)
266 # -> moved before include(ConfigureChecks.cmake)
267
268 #AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto)
269 #selinux missing
270
271 #AC_ARG_ENABLE(dnotify, AS_HELP_STRING([--enable-dnotify],[build with dnotify support (linux only)]),enable_dnotify=$enableval,enable_dnotify=auto)
272 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
273     OPTION(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX "build with dnotify support (linux only)" ON) # add a check !
274 endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
275
276 #AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support (FreeBSD only)]),enable_kqueue=$enableval,enable_kqueue=auto)
277 #missing
278
279 #AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto)
280 STRING(TOUPPER ${CMAKE_SYSTEM_NAME} sysname)
281 if("${sysname}" MATCHES ".*SOLARIS.*")
282     OPTION(HAVE_CONSOLE_OWNER_FILE "enable console owner file (solaris only)" ON)
283     if(HAVE_CONSOLE_OWNER_FILE)
284         SET(DBUS_CONSOLE_OWNER_FILE "/dev/console" CACHE STRING "Directory to check for console ownerhip")
285     endif(HAVE_CONSOLE_OWNER_FILE)
286 endif("${sysname}" MATCHES ".*SOLARIS.*")
287
288 #AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use]))
289 if(NOT LIBXML2_FOUND AND NOT LIBEXPAT_FOUND)
290     message(FATAL "Neither expat nor libxml2 found!")
291 endif(NOT LIBXML2_FOUND AND NOT LIBEXPAT_FOUND)
292
293 if(LIBEXPAT_FOUND)
294     OPTION(DBUS_USE_EXPAT "Use expat (== ON) or libxml2 (==OFF)" ON)
295 else(LIBEXPAT_FOUND)
296     OPTION(DBUS_USE_EXPAT "Use expat (== ON) or libxml2 (==OFF)" OFF)
297 endif(LIBEXPAT_FOUND)
298
299 if(DBUS_USE_EXPAT)
300     SET(XML_LIB "Expat")
301     SET(XML_LIBRARY     ${LIBEXPAT_LIBRARIES})
302     SET(XML_INCLUDE_DIR ${LIBEXPAT_INCLUDE_DIR})
303 else(DBUS_USE_EXPAT)
304     SET(XML_LIB "LibXML2")
305     SET(XML_LIBRARY     ${LIBXML2_LIBRARIES})
306     SET(XML_INCLUDE_DIR ${LIBXML2_INCLUDE_DIR})
307 endif(DBUS_USE_EXPAT)
308
309
310 #AC_ARG_WITH(init-scripts, AS_HELP_STRING([--with-init-scripts=[redhat]],[Style of init scripts to install]))
311 #AC_ARG_WITH(session-socket-dir, AS_HELP_STRING([--with-session-socket-dir=[dirname]],[Where to put sockets for the per-login-session message bus]))
312 #AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check]))
313 #AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[PID file for systemwide daemon]))
314 #AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon]))
315 #AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip]))
316 #AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filename]],[file whose owner determines current console owner]))
317 #AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
318 #AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon]))
319 # all missing or hardcoded for now
320
321 # 'hidden' ones
322 set(atomic_int OFF)
323 set(atomic_int486 OFF)
324 if(CMAKE_COMPILER_IS_GNUCC AND NOT DBUS_ENABLE_ANSI)
325     FIND_PROGRAM(UNAME_EXECUTABLE
326                     NAMES uname
327                     PATHS /bin /usr/bin /usr/local/bin c:/Programme/MSys/bin d:/Programme/MSys/bin)
328
329     if(UNAME_EXECUTABLE)
330         EXECUTE_PROCESS(COMMAND ${UNAME_EXECUTABLE} "-m"
331                         OUTPUT_VARIABLE UNAME_OUTPUT)
332
333         if("UNAME_OUTPUT" MATCHES "^.*i[0123]86.*$")
334             set(atomic_int ON)
335         else("UNAME_OUTPUT" MATCHES "^.*i[0123]86.*$")
336             if("UNAME_OUTPUT" MATCHES "^.*i?86.*$")
337                 set(atomic_int ON)
338                 set(atomic_int_486 ON)
339             endif("UNAME_OUTPUT" MATCHES "^.*i?86.*$")
340         endif("UNAME_OUTPUT" MATCHES "^.*i[0123]86.*$")
341     endif(UNAME_EXECUTABLE)
342 endif(CMAKE_COMPILER_IS_GNUCC AND NOT DBUS_ENABLE_ANSI)
343
344 OPTION(DBUS_HAVE_ATOMIC_INT    "Some atomic integer implementation present" ${atomic_int})
345 OPTION(DBUS_USE_ATOMIC_INT_486 "Use atomic integer implementation for 486" ${atomic_int_486})
346
347 if(X11_FOUND)
348   OPTION(DBUS_BUILD_X11 "Build X11-dependent code " ON)
349 endif(X11_FOUND)
350
351 # test binary names
352 if (WIN32)
353         set (EXT ".exe")
354 endif(WIN32)
355
356 if (MSVC_IDE)
357     if(CMAKE_BUILD_TYPE MATCHES Debug)
358                 set(IDE_BIN Debug/ )
359                 message(STATUS)
360                 message(STATUS "Visual Studio: test programs will only work with 'Debug' configuration!")
361                 message(STATUS "To run tests with 'Release' configuration use -DCMAKE_BUILD_TYPE=Release")
362                 message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs")
363                 message(STATUS)
364     else(CMAKE_BUILD_TYPE MATCHES Debug)
365                 set(IDE_BIN Release/)
366                 message(STATUS)
367                 message(STATUS "Visual Studio: test programs will only work with 'Release' configuration!")
368                 message(STATUS "To run tests with 'Debug' configuration use -DCMAKE_BUILD_TYPE=Debug")
369                 message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs")
370                 message(STATUS)
371     endif(CMAKE_BUILD_TYPE MATCHES Debug)
372         set (TEST_PATH_FORCE FORCE)
373         FILE(REMOVE ${CMAKE_BINARY_DIR}/data/dbus-1/services)
374 endif (MSVC_IDE)
375
376 set(TEST_SERVICE_DIR          ${CMAKE_BINARY_DIR}/test/data/valid-service-files     CACHE STRING "Full path to test file test/data/valid-service-files in builddir" )
377 set(TEST_SERVICE_BINARY       ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-service${EXT}       CACHE STRING "Full path to test file test/test-service in builddir" ${TEST_PATH_FORCE})
378 set(TEST_SHELL_SERVICE_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-shell-service${EXT} CACHE STRING "Full path to test file test/test-shell-service in builddir" ${TEST_PATH_FORCE})
379 set(TEST_EXIT_BINARY          ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-exit${EXT}          CACHE STRING "Full path to test file test/test-exit in builddir" ${TEST_PATH_FORCE})
380 set(TEST_SEGFAULT_BINARY      ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-segfault${EXT}      CACHE STRING "Full path to test file test/test-segfault in builddir" ${TEST_PATH_FORCE})
381 set(TEST_SLEEP_FOREVER_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-sleep-forever${EXT} CACHE STRING "Full path to test file test/test-sleep-forever in builddir" ${TEST_PATH_FORCE})
382
383 #### Find socket directories
384  if (NOT $ENV{TMPDIR} STREQUAL "")
385      set (DBUS_SESSION_SOCKET_DIR $ENV{TMPDIR})
386  else (NOT $ENV{TMPDIR} STREQUAL "")
387      if (NOT $ENV{TEMP} STREQUAL "")
388          set (DBUS_SESSION_SOCKET_DIR $ENV{TEMP})
389      else (NOT $ENV{TEMP} STREQUAL "")
390          if (NOT $ENV{TMP} STREQUAL "")
391              set (DBUS_SESSION_SOCKET_DIR $ENV{TMP})
392          else (NOT $ENV{TMP} STREQUAL "")
393          if (WIN32)
394              #Should never happen, both TMP and TEMP seem always set on Windows
395              message(FATAL "Could not determine a usable temporary directory")
396          else(WIN32)
397             set (DBUS_SESSION_SOCKET_DIR /tmp)
398          endif(WIN32)
399          endif (NOT $ENV{TMP} STREQUAL "")
400      endif (NOT $ENV{TEMP} STREQUAL "")
401  endif (NOT $ENV{TMPDIR} STREQUAL "")
402
403 #AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check]))
404
405 #AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[PID file for systemwide daemon]))
406
407 #if ! test -z "$with_system_pid_file"; then
408 #   DBUS_SYSTEM_PID_FILE=$with_system_pid_file
409 #elif test x$operating_system = xredhat ; then
410 #   DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid
411 #else
412 #   DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid
413 #fi
414 # TODO: fix redhet
415 if (WIN32)
416   # bus-test expects a non empty string
417         set (DBUS_SYSTEM_PID_FILE "/dbus-pid")
418 else (WIN32)
419         set (DBUS_SYSTEM_PID_FILE ${EXPANDED_LOCALSTATEDIR}/run/dbus/pid)
420 endif (WIN32)
421
422 #AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon]))
423
424 #AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip]))
425
426 if (WIN32)
427         set (DBUS_CONSOLE_AUTH_DIR "")
428 else (WIN32)
429         set (DBUS_CONSOLE_AUTH_DIR "/var/run/console/")
430 endif (WIN32)
431
432 #AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
433
434 set (DBUS_USER )
435
436
437 if (WIN32)
438   set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "system bus default address" )
439   set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "session bus default address" )
440
441   set (DBUS_SYSTEM_CONFIG_FILE "etc/dbus-1/system.conf")
442   set (DBUS_SESSION_CONFIG_FILE "etc/dbus-1/session.conf")
443   # bus-test expects a non empty string
444   set (DBUS_USER "Administrator")
445 else (WIN32)
446   set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:tmpdir=" CACHE STRING "system bus default address" )
447   set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default address" )
448   set (sysconfdir "")
449   set (configdir ${sysconfdir}/dbus-1 )
450   set (DBUS_SYSTEM_CONFIG_FILE  ${configdir}/system.conf)
451   set (DBUS_SESSION_CONFIG_FILE ${configdir}/session.conf)
452   set (DBUS_USER "root")
453 endif (WIN32)
454
455 set(DBUS_DAEMON_NAME dbus-daemon CACHE STRING "The name of the dbus daemon executable")
456
457 ########### create config.h ###############
458
459 #include(ConfigureChecks.cmake)
460
461 # better use flags for gcc
462 if (MINGW)
463         set (HAVE_GNUC_VARARGS 1)
464 endif(MINGW)
465
466 # compiler definitions
467 add_definitions(-DHAVE_CONFIG_H=1)
468 add_definitions(${DBUS_BUS_CFLAGS} -DDBUS_API_SUBJECT_TO_CHANGE)
469
470
471 if (DBUS_BUILD_TESTS)
472     # set variables used for the .in files (substituted by configure_file) in test/data:
473     set(TEST_VALID_SERVICE_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files)
474     set(TEST_VALID_SERVICE_SYSTEM_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files-system)
475     set(TEST_INVALID_SERVICE_SYSTEM_DIR ${CMAKE_BINARY_DIR}/test/data/invalid-service-files-system)
476     set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR} )
477     set(TEST_LAUNCH_HELPER_BINARY ${EXECUTABLE_OUTPUT_PATH}/dbus-daemon-launch-helper-test)
478     set(TEST_PRIVSERVER_BINARY ${EXECUTABLE_OUTPUT_PATH}/test-privserver)
479     if (UNIX)
480         set (TEST_LISTEN "debug-pipe:name=test-server</listen><listen>unix:tmpdir=${TEST_SOCKET_DIR}")
481         set (TEST_CONNECTION "debug-pipe:name=test-server")
482     endif (UNIX)
483     if (WIN32)
484         set (TEST_LISTEN "tcp:host=localhost,port=12436")
485         set (TEST_CONNECTION "${TEST_LISTEN}")
486     endif (WIN32)
487 endif  (DBUS_BUILD_TESTS)
488
489 set(DBUS_LIBRARIES dbus-1)
490 set(DBUS_INTERNAL_LIBRARIES dbus-internal)
491
492 # settings for building and using static internal lib
493 # important note: DBUS_INTERNAL_xxxxx_DEFINITIONS must *not* be set when building dbus-1 library
494 set (DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC)
495 set (DBUS_INTERNAL_LIBRARY_DEFINITIONS "-DDBUS_STATIC_BUILD")
496 set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD")
497
498 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
499 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-env.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-env.bat )
500 install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat)
501 add_definitions(-DHAVE_CONFIG_H=1)
502
503 ########### subdirs ###############
504
505 add_subdirectory( dbus )
506 add_subdirectory( bus )
507 if (DBUS_BUILD_TESTS)
508         add_subdirectory( test )
509 endif (DBUS_BUILD_TESTS)
510 add_subdirectory( tools )
511 add_subdirectory( doc )
512
513
514 OPTION(DBUS_INSTALL_SYSTEM_LIBS "install required system libraries" OFF)
515 MESSAGE(" ")
516 MESSAGE("set -DDBUS_INSTALL_SYSTEM_LIBS=1 to install runtime libraries too")
517 MESSAGE("set DBUSDIR (environment or cmake option) to overwrite the default install directory ")
518 MESSAGE(" ")
519 MESSAGE(" ")
520 GET_FILENAME_COMPONENT(C_COMPILER ${CMAKE_C_COMPILER} NAME)
521 GET_FILENAME_COMPONENT(CXX_COMPILER ${CMAKE_CXX_COMPILER} NAME)
522
523 message("                  D-BUS ${DBUS_VERSION}                               ")
524 message("                  ===========                                         ")
525 message("                                                                      ")
526 message("        install prefix:           ${prefix}                           ")
527 message("        install exec_prefix:      ${exec_prefix}                      ")
528 message("        install libdir:           ${EXPANDED_LIBDIR}                  ")
529 message("        install bindir:           ${EXPANDED_BINDIR}                  ")
530 message("        install sysconfdir:       ${EXPANDED_SYSCONFDIR}              ")
531 #message("        install localstatedir:    ${EXPANDED_LOCALSTATEDIR}           ")
532 message("        install datadir:          ${EXPANDED_DATADIR}                 ")
533 message("        source code location:     ${DBUS_SOURCE_DIR}                  ")
534 message("        build dir:                ${CMAKE_BINARY_DIR}                 ")
535 message("        c compiler:               ${C_COMPILER}                       ")
536 message("        cflags:                   ${CMAKE_C_FLAGS}                    ")
537 message("        cflags debug:             ${CMAKE_C_FLAGS_DEBUG}              ")
538 message("        cflags release:           ${CMAKE_C_FLAGS_RELEASE}            ")
539 message("        cxx compiler:             ${CXX_COMPILER}                     ")
540 message("        cxxflags:                 ${CMAKE_CXX_FLAGS}                  ")
541 message("        cxxflags debug:           ${CMAKE_CXX_FLAGS_DEBUG}            ")
542 message("        cxxflags release:         ${CMAKE_CXX_FLAGS_RELEASE}          ")
543 message("        64-bit int:               ${DBUS_INT64_TYPE}                  ")
544 message("        32-bit int:               ${DBUS_INT32_TYPE}                  ")
545 message("        16-bit int:               ${DBUS_INT16_TYPE}                  ")
546 message("        Doxygen:                  ${DOXYGEN}                          ")
547 message("        Docbook Generator:        ${DOCBOOK_GENERATOR_NAME}           ")
548
549
550 #message("        Maintainer mode:          ${USE_MAINTAINER_MODE}              ")
551 message("        gcc coverage profiling:   ${DBUS_GCOV_ENABLED}                ")
552 message("        Building unit tests:      ${DBUS_BUILD_TESTS}                 ")
553 message("        Building verbose mode:    ${DBUS_ENABLE_VERBOSE_MODE}         ")
554 message("        Building w/o assertions:  ${DBUS_DISABLE_ASSERTS}             ")
555 message("        Building w/o checks:      ${DBUS_DISABLE_CHECKS}              ")
556 message("        installing system libs:   ${DBUS_INSTALL_SYSTEM_LIBS}         ")
557 #message("        Building SELinux support: ${have_selinux}                     ")
558 #message("        Building dnotify support: ${have_dnotify}                     ")
559 message("        Building Doxygen docs:    ${DBUS_ENABLE_DOXYGEN_DOCS}         ")
560 message("        Building XML docs:        ${DBUS_ENABLE_XML_DOCS}             ")
561 #message("        Gettext libs (empty OK):  ${INTLLIBS}                         ")
562 message("        Using XML parser:         ${XML_LIB}                          ")
563 message("        Daemon executable name:   ${DBUS_DAEMON_NAME}")
564 if (WIN32)
565 message("        System bus address:       ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}  ")
566 message("        Session bus address:      ${DBUS_SESSION_BUS_DEFAULT_ADDRESS} ")
567 else (WIN32)
568 #message("        Init scripts style:       ${with_init_scripts}                ")
569 #message("        Abstract socket names:    ${have_abstract_sockets}            ")
570 message("        System bus socket:        ${DBUS_SYSTEM_SOCKET}               ")
571 message("        System bus address:       ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}  ")
572 message("        System bus PID file:      ${DBUS_SYSTEM_PID_FILE}             ")
573 message("        Session bus socket dir:   ${DBUS_SESSION_SOCKET_DIR}          ")
574 message("        Console auth dir:         ${DBUS_CONSOLE_AUTH_DIR}            ")
575 message("        System bus user:          ${DBUS_USER}                        ")
576 message("        'make check' socket dir:  ${TEST_SOCKET_DIR}                  ")
577 endif (WIN32)
578 message("        Test listen address:      ${TEST_LISTEN}                      ")
579 if (MSVC)
580 message("        build timestamp:          ${DBUS_BUILD_TIMESTAMP}             ")
581 endif (MSVC)
582
583 MESSAGE(" ")
584 if (DBUS_BUILD_TESTS)
585     message("NOTE: building with unit tests increases the size of the installed library and renders it insecure.")
586 endif(DBUS_BUILD_TESTS)
587
588 if (DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERTS)
589     message("NOTE: building with unit tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)")
590 endif(DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERTS)
591
592 if (DBUS_GCOV_ENABLED)
593     message("NOTE: building with coverage profiling is definitely for developers only.")
594 endif(DBUS_GCOV_ENABLED)
595
596 if (DBUS_ENABLE_VERBOSE_MODE)
597     message("NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance.")
598 endif(DBUS_ENABLE_VERBOSE_MODE)
599
600 if(NOT DBUS_DISABLE_ASSERTS)
601     message("NOTE: building with assertions increases library size and decreases performance.")
602 endif(NOT DBUS_DISABLE_ASSERTS)
603
604 if (DBUS_DISABLE_CHECKS)
605     message("NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-BUS, but will slightly decrease D-BUS library size and _very_ slightly improve performance.")
606 endif(DBUS_DISABLE_CHECKS)
607 MESSAGE(" ")
608
609 INCLUDE(modules/CPackInstallConfig.cmake)