Merge branch 'dbus-1.10'
[platform/upstream/dbus.git] / cmake / CMakeLists.txt
1 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
2 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
3
4 # we do not need to have WIN32 defined
5 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
6
7 project(dbus)
8
9 # we need to be up to date
10 CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
11 if(COMMAND cmake_policy)
12     cmake_policy(SET CMP0003 NEW)
13 endif(COMMAND cmake_policy)
14
15 if(CMAKE_MAJOR_VERSION GREATER 2)
16     cmake_policy(SET CMP0026 NEW)
17     if (CMAKE_MAJOR_VERSION GREATER 4 OR CMAKE_MINOR_VERSION GREATER 1)
18         cmake_policy(SET CMP0053 NEW)
19         cmake_policy(SET CMP0054 NEW)
20     endif()
21 endif()
22
23 # detect version
24 include(MacrosAutotools)
25 autoinit(../configure.ac)
26 autoversion(dbus)
27
28 if(EXISTS ../config.h.in)
29     autoheaderchecks(../config.h.in ConfigureChecks.cmake config.h.cmake)
30 else()
31     message(STATUS "Generate config.h.in with autogen.sh to enable cmake header difference check.")
32 endif()
33
34 # used by file version info
35 set (DBUS_PATCH_VERSION "0")
36
37 # set PACKAGE_... variables
38 autopackage(
39     dbus
40     ${DBUS_VERSION_STRING}
41     "http://dbus.freedesktop.org"
42     "https://bugs.freedesktop.org/enter_bug.cgi?product=dbus"
43 )
44
45 include(Macros)
46 TIMESTAMP(DBUS_BUILD_TIMESTAMP)
47
48 ########### basic vars ###############
49
50
51 if (DBUSDIR)
52         set(DBUS_INSTALL_DIR "${DBUSDIR}")
53 endif (DBUSDIR)
54 if ($ENV{DBUSDIR})
55         set(DBUS_INSTALL_DIR "$ENV{DBUSDIR}")
56 endif ($ENV{DBUSDIR})
57
58 if (DBUS_INSTALL_DIR)
59         set(CMAKE_INSTALL_PREFIX "${DBUS_INSTALL_DIR}" CACHE PATH "install prefix" FORCE)
60 else (DBUS_INSTALL_DIR)
61         set(DBUS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
62 endif (DBUS_INSTALL_DIR)
63
64 set(DBUS_PREFIX ${DBUS_INSTALL_DIR})
65
66 set(prefix                   ${DBUS_INSTALL_DIR})
67 set(exec_prefix              ${prefix})
68 set(EXPANDED_LIBDIR          ${DBUS_INSTALL_DIR}/lib)
69 set(EXPANDED_INCLUDEDIR      ${DBUS_INSTALL_DIR}/include)
70 set(EXPANDED_BINDIR          ${DBUS_INSTALL_DIR}/bin)
71 set(EXPANDED_SYSCONFDIR      ${DBUS_INSTALL_DIR}/etc)
72 set(EXPANDED_LOCALSTATEDIR   ${DBUS_INSTALL_DIR}/var)
73 set(EXPANDED_DATADIR         ${DBUS_INSTALL_DIR}/share)
74 set(DBUS_MACHINE_UUID_FILE   ${DBUS_INSTALL_DIR}/lib/dbus/machine-id)
75 set(DBUS_BINDIR              ${EXPANDED_BINDIR})
76 set(DBUS_DAEMONDIR           ${EXPANDED_BINDIR})
77 set(DBUS_LOCALSTATEDIR       ${EXPANDED_LOCALSTATEDIR})
78
79 # On Windows this is relative to where we put the bus setup, in
80 # ${datadir}/dbus-1. For simplicity, we only do this if
81 # ${sysconfdir} = ${prefix}/etc and ${datadir} = ${prefix}/share.
82 #
83 # On Unix, or on Windows with weird install layouts, it's the absolute path.
84 if(WIN32 AND ${EXPANDED_SYSCONFDIR} STREQUAL ${prefix}/etc AND ${EXPANDED_DATADIR} STREQUAL ${prefix}/share)
85 set(SYSCONFDIR_FROM_PKGDATADIR ../../etc)
86 set(DATADIR_FROM_PKGSYSCONFDIR ../../share)
87 else()
88 set(SYSCONFDIR_FROM_PKGDATADIR ${EXPANDED_SYSCONFDIR})
89 set(DATADIR_FROM_PKGSYSCONFDIR ${EXPANDED_DATADIR})
90 endif()
91
92 # used in the C code
93 set(DBUS_LIBEXECDIR          ${EXPANDED_LIBDIR})
94 set(DBUS_DATADIR             ${EXPANDED_DATADIR})
95
96 #enable building of shared library
97 SET(BUILD_SHARED_LIBS ON)
98
99 if(WIN32)
100     set(INSTALL_TARGETS_DEFAULT_ARGS  RUNTIME DESTINATION "bin" LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib")
101 else()
102     set(INSTALL_TARGETS_DEFAULT_ARGS  RUNTIME DESTINATION "${EXPANDED_LIBDIR}" LIBRARY DESTINATION "${EXPANDED_LIBDIR}" ARCHIVE DESTINATION "${EXPANDED_LIBDIR}")
103 endif()
104
105 if (CYGWIN)
106    set (WIN32)
107 endif (CYGWIN)
108
109 # search for required packages
110 if (WIN32)
111     # include local header first to avoid using old installed header
112     set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/..)
113         find_package(LibIconv)
114     include(Win32Macros)
115     addExplorerWrapper(${CMAKE_PROJECT_NAME})
116 endif (WIN32)
117
118 if(NOT WIN32)
119         option (DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON)
120         set (CMAKE_THREAD_PREFER_PTHREAD ON)
121         include (FindThreads)
122 endif(NOT WIN32)
123
124 option (DBUS_DISABLE_ASSERT "Disable assertion checking" OFF)
125
126 option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF)
127
128 if(WIN32)
129     set(FD_SETSIZE "8192" CACHE STRING "The maximum number of connections that can be handled at once")
130 endif()
131
132 find_package(EXPAT)
133 find_package(X11)
134 find_package(GLib2)
135 find_package(GObject)
136 if(GLIB2_FOUND AND GOBJECT_FOUND)
137     option (DBUS_WITH_GLIB "build with glib" ON)
138 endif()
139
140 # analogous to AC_USE_SYSTEM_EXTENSIONS in configure.ac
141 add_definitions(-D_GNU_SOURCE)
142
143 # do config checks
144 INCLUDE(ConfigureChecks.cmake)
145
146 # @TODO: how to remove last dir from ${CMAKE_SOURCE_DIR} ?
147 SET(DBUS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/..)
148
149 # make some more macros available
150 include (MacroLibrary)
151
152 if(VCS)
153         set(DBUS_VERBOSE_C_S 1 CACHE STRING "verbose mode" FORCE)
154 endif(VCS)
155
156 if(WIN32)
157         if(MSVC)
158                 # controll folders in msvc projects
159                 include(ProjectSourceGroup)
160                 if(NOT GROUP_CODE)
161                         #set(GROUP_CODE split) #cmake default
162                         set(GROUP_CODE flat)
163                 endif(NOT GROUP_CODE)
164                 ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
165
166
167                 # Use the highest warning level
168                 if (WALL)
169                         set(WALL 1 CACHE STRING "all warnings"  FORCE)
170                         set(CMAKE_CXX_WARNING_LEVEL 4 CACHE STRING "warning level" FORCE)
171
172                         if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
173                                 STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
174                         else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
175                                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
176                         endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
177
178                         if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
179                                 STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
180                         else(CMAKE_C_FLAGS MATCHES "/W[0-4]")
181                                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
182                         endif(CMAKE_C_FLAGS MATCHES "/W[0-4]")
183                 else (WALL)
184                         set(CMAKE_CXX_WARNING_LEVEL 3 CACHE STRING "warning level" FORCE)
185                 endif (WALL)
186
187                 SET(MSVC_W_ERROR   " /we4028 /we4013 /we4133 /we4047 /we4031 /we4002 /we4003 /we4114")
188                 SET(MSVC_W_DISABLE " /wd4127 /wd4090 /wd4101 /wd4244")
189
190                 SET(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG}   /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}")
191                 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}")
192         endif(MSVC)
193 endif(WIN32)
194
195 if (UNIX AND NOT DBUS_DISABLE_ASSERT)
196         # required for backtrace
197         SET(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG}   -Wl,--export-dynamic")
198         SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wl,--export-dynamic")
199         add_definitions(-DDBUS_BUILT_R_DYNAMIC)
200 endif (UNIX AND NOT DBUS_DISABLE_ASSERT)
201
202 if(DBUS_WITH_GLIB)
203     autodefine(GLIB_VERSION_MIN_REQUIRED)
204     autodefine(GLIB_VERSION_MAX_ALLOWED)
205 endif()
206
207 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}  -D_DEBUG")
208 if(MSVC)
209     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  /w14018")
210     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w14018")
211 else()
212     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  -Wsign-compare")
213     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -Wsign-compare")
214 endif()
215
216 #########################################################################
217 # Windows CE (>= 5.0.0)
218 #
219 # WinCE support now relies on the presence of platform files, found in cmake/modules/platform
220 # Cmake 2.8.0 doesn't include WinCE platform files by default, but working ones can be found
221 # on CMake's bugtracker :
222 # http://public.kitware.com/Bug/view.php?id=7919
223 #
224 # for cmake 2.8.0 get the following patch only :
225 # http://public.kitware.com/Bug/file_download.php?file_id=2944&type=bug
226 #
227 # after applying the patch, you can enable the WinCE build by specifying :
228 # cmake [...] -DCMAKE_SYSTEM_NAME=WinCE -DCMAKE_SYSTEM_VERSION=X.XX
229 # (where X.XX is your actual WinCE version, e.g. 5.02 for Windows Mobile 6)
230 #
231 # Note that you should have a proper cross-compilation environment set up prior to running
232 # cmake, ie. the PATH, INCLUDE and LIB env vars pointing to your CE SDK/toolchain.
233 #
234 if(WINCE)
235
236 MESSAGE("Building for WinCE (${CMAKE_SYSTEM_VERSION})")
237
238 endif(WINCE)
239 #########################################################################
240
241
242 ENABLE_TESTING()
243
244 #########################################################################
245 # Disallow in-source build
246 #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.")
247
248 # ... and warn in case of an earlier in-source build
249 #set(generatedFileInSourceDir EXISTS ${dbus_SOURCE_DIR}/config.h)
250 #if(${generatedFileInSourceDir})
251 #   message(STATUS "config.h exists in your source directory.")
252 #endif(${generatedFileInSourceDir})
253 #########################################################################
254
255 if (WIN32 OR CYGWIN)
256         set (LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/bin)
257 else (WIN32 OR CYGWIN)
258         set (LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
259 endif (WIN32 OR CYGWIN)
260
261 set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
262
263 # for including config.h and for includes like <dir/foo.h>
264 include_directories( ${CMAKE_SOURCE_DIR}/.. ${CMAKE_BINARY_DIR} ${CMAKE_INCLUDE_PATH} )
265
266 # linker search directories
267 link_directories(${DBUS_LIB_DIR} ${LIBRARY_OUTPUT_PATH} )
268 include_directories( ${CMAKE_LIBRARY_PATH}  )
269
270 set(DBUS_INCLUDES)
271
272 ENABLE_TESTING()
273
274 ########### command line options ###############
275 # TODO: take check from configure.in
276
277 option (DBUS_BUILD_TESTS "enable unit test code" ON)
278  
279 if(DBUS_BUILD_TESTS)
280     set (DBUS_ENABLE_EMBEDDED_TESTS ON)
281     set (DBUS_ENABLE_MODULAR_TESTS ON)
282     add_definitions(-DDBUS_ENABLE_EMBEDDED_TESTS -DDBUS_ENABLE_MODULAR_TESTS)
283 endif(DBUS_BUILD_TESTS)
284
285 option (DBUS_USE_OUTPUT_DEBUG_STRING "enable win32 debug port for message output" OFF)
286 if(DBUS_USE_OUTPUT_DEBUG_STRING)
287     add_definitions(-DDBUS_USE_OUTPUT_DEBUG_STRING)
288 endif(DBUS_USE_OUTPUT_DEBUG_STRING)
289
290 if(WIN32)
291         # win32 dbus service support - this support is not complete
292         option (DBUS_SERVICE "enable dbus service installer" OFF)
293 endif(WIN32)
294
295 option (DBUS_ENABLE_ANSI "enable -ansi -pedantic gcc flags" OFF)
296 if(DBUS_ENABLE_ANSI)
297    if(NOT MSVC)
298         add_definitions(-ansi -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -pedantic)
299    else(NOT MSVC)
300         add_definitions(-Za -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -W4)
301    endif(NOT MSVC)
302 endif(DBUS_ENABLE_ANSI)
303
304 option (DBUS_ENABLE_VERBOSE_MODE "support verbose debug mode" ON)
305
306 option (DBUS_DISABLE_CHECKS "Disable public API sanity checking" OFF)
307
308 if(NOT MSVC)
309     option (DBUS_GCOV_ENABLED "compile with coverage profiling instrumentation (gcc only)" OFF)
310     if(DBUS_GCOV_ENABLED)
311             add_definitions(-fprofile-arcs -ftest-coverage)
312             # FIXME!!!!
313             ## remove optimization
314     #        CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
315     endif(DBUS_GCOV_ENABLED)
316 endif(NOT MSVC)
317
318 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
319     option (DBUS_BUS_ENABLE_INOTIFY "build with inotify support (linux only)" ON)
320     if(DBUS_BUS_ENABLE_INOTIFY)
321         if(NOT HAVE_SYS_INOTIFY_H)
322             message(FATAL_ERROR "sys/inotify.h not found!")
323         endif(NOT HAVE_SYS_INOTIFY_H)
324     endif(DBUS_BUS_ENABLE_INOTIFY)
325 elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*BSD")
326     option (DBUS_BUS_ENABLE_KQUEUE "build with kqueue support (FreeBSD only)" ON)
327     if(DBUS_BUS_ENABLE_KQUEUE)
328         if(NOT HAVE_SYS_EVENT_H)
329             message(FATAL_ERROR "sys/event.h not found!")
330         endif(NOT HAVE_SYS_EVENT_H)
331     endif(DBUS_BUS_ENABLE_KQUEUE)
332 endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
333
334 STRING(TOUPPER ${CMAKE_SYSTEM_NAME} sysname)
335 if("${sysname}" MATCHES ".*SOLARIS.*")
336     option (HAVE_CONSOLE_OWNER_FILE "enable console owner file (solaris only)" ON)
337     if(HAVE_CONSOLE_OWNER_FILE)
338         set (DBUS_CONSOLE_OWNER_FILE "/dev/console" CACHE STRING "Directory to check for console ownerhip")
339     endif(HAVE_CONSOLE_OWNER_FILE)
340 endif("${sysname}" MATCHES ".*SOLARIS.*")
341
342 if(NOT EXPAT_FOUND)
343     message(FATAL_ERROR "expat not found!")
344 endif(NOT EXPAT_FOUND)
345
346 SET(XML_LIB "Expat")
347 SET(XML_LIBRARY     ${EXPAT_LIBRARIES})
348 SET(XML_INCLUDE_DIR ${EXPAT_INCLUDE_DIR})
349
350 # all missing or hardcoded for now
351
352 # 'hidden' ones
353 set(atomic_int OFF)
354 set(atomic_int486 OFF)
355 if(CMAKE_COMPILER_IS_GNUCC AND NOT DBUS_ENABLE_ANSI)
356     FIND_PROGRAM(UNAME_EXECUTABLE
357                     NAMES uname
358                     PATHS /bin /usr/bin /usr/local/bin c:/Programme/MSys/bin d:/Programme/MSys/bin)
359
360     if(UNAME_EXECUTABLE)
361         EXECUTE_PROCESS(COMMAND ${UNAME_EXECUTABLE} "-m"
362                         OUTPUT_VARIABLE UNAME_OUTPUT)
363
364         if("UNAME_OUTPUT" MATCHES "^.*i[0123]86.*$")
365             set(atomic_int ON)
366         else("UNAME_OUTPUT" MATCHES "^.*i[0123]86.*$")
367             if("UNAME_OUTPUT" MATCHES "^.*i?86.*$")
368                 set(atomic_int ON)
369                 set(atomic_int_486 ON)
370             endif("UNAME_OUTPUT" MATCHES "^.*i?86.*$")
371         endif("UNAME_OUTPUT" MATCHES "^.*i[0123]86.*$")
372     endif(UNAME_EXECUTABLE)
373 endif(CMAKE_COMPILER_IS_GNUCC AND NOT DBUS_ENABLE_ANSI)
374
375 set (DBUS_HAVE_ATOMIC_INT ${atomic_int} CACHE STRING "Some atomic integer implementation present")
376 set (DBUS_USE_ATOMIC_INT_486 ${atomic_int_486} CACHE STRING "Use atomic integer implementation for 486")
377
378 if(X11_FOUND)
379   option (DBUS_BUILD_X11 "Build with X11 autolaunch support " ON)
380 endif(X11_FOUND)
381
382 # test binary names
383 if (WIN32)
384     # follow Automake's naming convention so we can share .in files
385     set (EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
386 endif(WIN32)
387
388 if (MSVC_IDE)
389     if(CMAKE_BUILD_TYPE MATCHES Debug)
390                 set(IDE_BIN /Debug )
391                 message(STATUS)
392                 message(STATUS "Visual Studio: test programs will only work with 'Debug' configuration!")
393                 message(STATUS "To run tests with 'Release' configuration use -DCMAKE_BUILD_TYPE=Release")
394                 message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs")
395                 message(STATUS)
396     else(CMAKE_BUILD_TYPE MATCHES Debug)
397                 set(IDE_BIN /Release)
398                 message(STATUS)
399                 message(STATUS "Visual Studio: test programs will only work with 'Release' configuration!")
400                 message(STATUS "To run tests with 'Debug' configuration use -DCMAKE_BUILD_TYPE=Debug")
401                 message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs")
402                 message(STATUS)
403     endif(CMAKE_BUILD_TYPE MATCHES Debug)
404         set (TEST_PATH_FORCE FORCE)
405         FILE(REMOVE ${CMAKE_BINARY_DIR}/data/dbus-1/services)
406 endif (MSVC_IDE)
407
408 #### Find socket directories
409  if (NOT $ENV{TMPDIR} STREQUAL "")
410      set (DBUS_SESSION_SOCKET_DIR $ENV{TMPDIR})
411  else (NOT $ENV{TMPDIR} STREQUAL "")
412      if (NOT $ENV{TEMP} STREQUAL "")
413          set (DBUS_SESSION_SOCKET_DIR $ENV{TEMP})
414      else (NOT $ENV{TEMP} STREQUAL "")
415          if (NOT $ENV{TMP} STREQUAL "")
416              set (DBUS_SESSION_SOCKET_DIR $ENV{TMP})
417          else (NOT $ENV{TMP} STREQUAL "")
418          if (WIN32)
419              #Should never happen, both TMP and TEMP seem always set on Windows
420              message(FATAL_ERROR "Could not determine a usable temporary directory")
421          else(WIN32)
422             set (DBUS_SESSION_SOCKET_DIR /tmp)
423          endif(WIN32)
424          endif (NOT $ENV{TMP} STREQUAL "")
425      endif (NOT $ENV{TEMP} STREQUAL "")
426  endif (NOT $ENV{TMPDIR} STREQUAL "")
427
428  # Not used on Windows, where there is no system bus
429 set (DBUS_SYSTEM_PID_FILE ${DBUS_LOCALSTATEDIR}/run/dbus/pid)
430
431 if (WIN32)
432         set (DBUS_CONSOLE_AUTH_DIR "")
433 else (WIN32)
434         set (DBUS_CONSOLE_AUTH_DIR "/var/run/console/")
435 endif (WIN32)
436
437 # This won't work on Windows. It's not meant to - the system bus is
438 # meaningless on Windows anyway.
439 #
440 # This has to be suitable for hard-coding in client libraries as well as
441 # in the dbus-daemon's configuration, so it has to be valid to listen on
442 # and also to connect to. If this ever changes, it'll need to be split into
443 # two variables, one for the listening address and one for the connecting
444 # address.
445 set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_LOCALSTATEDIR}/run/dbus/system_bus_socket" CACHE STRING "system bus default address")
446
447 if (WIN32)
448   set (DBUS_SESSION_BUS_LISTEN_ADDRESS "autolaunch:" CACHE STRING "session bus default listening address")
449   set (DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients")
450
451   set (DBUS_SYSTEM_CONFIG_FILE "share/dbus-1/system.conf")
452   set (DBUS_SESSION_CONFIG_FILE "share/dbus-1/session.conf")
453   # bus-test expects a non empty string
454   set (DBUS_USER "Administrator")
455   set (DBUS_TEST_USER "guest")
456   set (DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL "<!--<auth>EXTERNAL</auth>-->")
457 else (WIN32)
458   set (DBUS_SESSION_BUS_LISTEN_ADDRESS "unix:tmpdir=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default listening address")
459   set (DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients")
460   set (sysconfdir "")
461   set (configdir ${sysconfdir}/dbus-1 )
462   set (DBUS_SYSTEM_CONFIG_FILE  ${configdir}/system.conf)
463   set (DBUS_SESSION_CONFIG_FILE ${configdir}/session.conf)
464   set (DBUS_USER "messagebus")
465   set (DBUS_TEST_USER "nobody")
466   # For best security, assume that all non-Windows platforms can do
467   # credentials-passing.
468   set (DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL "<auth>EXTERNAL</auth>")
469 endif (WIN32)
470
471 set (DBUS_DAEMON_NAME "dbus-daemon" CACHE STRING "The name of the dbus daemon executable")
472
473 ########### create config.h ###############
474
475 #include(ConfigureChecks.cmake)
476
477 # better use flags for gcc
478 if (MINGW)
479         set (HAVE_GNUC_VARARGS 1)
480 endif(MINGW)
481
482 # compiler definitions
483 add_definitions(-DHAVE_CONFIG_H=1)
484 add_definitions(${DBUS_BUS_CFLAGS})
485
486
487 if (DBUS_BUILD_TESTS)
488     # set variables used for the .in files (substituted by configure_file) in test/data:
489     set(DBUS_TEST_EXEC ${EXECUTABLE_OUTPUT_PATH}${IDE_BIN})
490     set(DBUS_TEST_DATA ${CMAKE_BINARY_DIR}/test/data)
491     set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR} )
492     set(TEST_LAUNCH_HELPER_BINARY ${EXECUTABLE_OUTPUT_PATH}/dbus-daemon-launch-helper-test)
493     set(TEST_BUS_LAUNCH_BINARY ${EXECUTABLE_OUTPUT_PATH}/dbus-launch${EXEEXT})
494     if (UNIX)
495         set (TEST_LISTEN "unix:tmpdir=${TEST_SOCKET_DIR}")
496     endif (UNIX)
497     if (WIN32)
498         set (TEST_LISTEN "tcp:host=localhost")
499     endif (WIN32)
500 endif  (DBUS_BUILD_TESTS)
501
502 set(DBUS_LIBRARIES dbus-1)
503 set(DBUS_INTERNAL_LIBRARIES dbus-internal)
504
505 set (DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC)
506 set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_COMPILATION")
507
508 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
509
510 if (WIN32)
511 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-env.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-env.bat )
512 install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat)
513 endif()
514
515 add_definitions(-DHAVE_CONFIG_H=1)
516
517 ########### subdirs ###############
518
519 add_subdirectory( dbus )
520 add_subdirectory( bus )
521 if (DBUS_BUILD_TESTS)
522         add_subdirectory( test )
523         add_custom_target(check
524                 COMMAND ctest -R ^test-.*
525         )
526 endif (DBUS_BUILD_TESTS)
527 add_subdirectory( tools )
528 add_subdirectory( doc )
529
530
531 OPTION(DBUS_INSTALL_SYSTEM_LIBS "install required system libraries" OFF)
532 MESSAGE(" ")
533 MESSAGE("set -DDBUS_INSTALL_SYSTEM_LIBS=1 to install runtime libraries too")
534 MESSAGE("set DBUSDIR (environment or cmake option) to overwrite the default install directory ")
535 MESSAGE(" ")
536 MESSAGE(" ")
537 GET_FILENAME_COMPONENT(C_COMPILER ${CMAKE_C_COMPILER} NAME)
538 GET_FILENAME_COMPONENT(CXX_COMPILER ${CMAKE_CXX_COMPILER} NAME)
539
540 message("                  D-BUS ${DBUS_VERSION}                               ")
541 message("                  ============                                        ")
542 message("                                                                      ")
543 message("        install prefix:           ${prefix}                           ")
544 message("        install exec_prefix:      ${exec_prefix}                      ")
545 message("        install libdir:           ${EXPANDED_LIBDIR}                  ")
546 message("        install bindir:           ${EXPANDED_BINDIR}                  ")
547 message("        install sysconfdir:       ${EXPANDED_SYSCONFDIR}              ")
548 message("        install datadir:          ${EXPANDED_DATADIR}                 ")
549 message("        source code location:     ${DBUS_SOURCE_DIR}                  ")
550 message("        build dir:                ${CMAKE_BINARY_DIR}                 ")
551 message("        c compiler:               ${C_COMPILER}                       ")
552 message("        cflags:                   ${CMAKE_C_FLAGS}                    ")
553 message("        cflags debug:             ${CMAKE_C_FLAGS_DEBUG}              ")
554 message("        cflags release:           ${CMAKE_C_FLAGS_RELEASE}            ")
555 message("        cxx compiler:             ${CXX_COMPILER}                     ")
556 message("        cxxflags:                 ${CMAKE_CXX_FLAGS}                  ")
557 message("        cxxflags debug:           ${CMAKE_CXX_FLAGS_DEBUG}            ")
558 message("        cxxflags release:         ${CMAKE_CXX_FLAGS_RELEASE}          ")
559 message("        64-bit int:               ${DBUS_INT64_TYPE}                  ")
560 message("        32-bit int:               ${DBUS_INT32_TYPE}                  ")
561 message("        16-bit int:               ${DBUS_INT16_TYPE}                  ")
562 message("        Doxygen:                  ${DOXYGEN}                          ")
563 message("        Docbook Generator:        ${DOCBOOK_GENERATOR_NAME}           ")
564
565
566 message("        gcc coverage profiling:   ${DBUS_GCOV_ENABLED}                ")
567 message("        Building unit tests:      ${DBUS_BUILD_TESTS}                 ")
568 message("        Building with GLib:       ${DBUS_WITH_GLIB}                   ")
569 message("        Building verbose mode:    ${DBUS_ENABLE_VERBOSE_MODE}         ")
570 message("        Building w/o assertions:  ${DBUS_DISABLE_ASSERT}              ")
571 message("        Building w/o checks:      ${DBUS_DISABLE_CHECKS}              ")
572 message("        Building bus stats API:   ${DBUS_ENABLE_STATS}                ")
573 message("        installing system libs:   ${DBUS_INSTALL_SYSTEM_LIBS}         ")
574 message("        Building inotify support: ${DBUS_BUS_ENABLE_INOTIFY}          ")
575 message("        Building kqueue support:  ${DBUS_BUS_ENABLE_KQUEUE}           ")
576 message("        Building Doxygen docs:    ${DBUS_ENABLE_DOXYGEN_DOCS}         ")
577 message("        Building XML docs:        ${DBUS_ENABLE_XML_DOCS}             ")
578 message("        Daemon executable name:   ${DBUS_DAEMON_NAME}")
579 if (WIN32)
580 message("        System bus address:       ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}  ")
581 message("        Session bus listens on:   ${DBUS_SESSION_BUS_LISTEN_ADDRESS}  ")
582 message("        Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} ")
583 else (WIN32)
584 message("        System bus socket:        ${DBUS_SYSTEM_SOCKET}               ")
585 message("        System bus address:       ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}  ")
586 message("        System bus PID file:      ${DBUS_SYSTEM_PID_FILE}             ")
587 message("        Session bus socket dir:   ${DBUS_SESSION_SOCKET_DIR}          ")
588 message("        Console auth dir:         ${DBUS_CONSOLE_AUTH_DIR}            ")
589 message("        System bus user:          ${DBUS_USER}                        ")
590 message("        'make check' socket dir:  ${TEST_SOCKET_DIR}                  ")
591 endif (WIN32)
592 message("        Test listen address:      ${TEST_LISTEN}                      ")
593 if (MSVC)
594 message("        build timestamp:          ${DBUS_BUILD_TIMESTAMP}             ")
595 endif (MSVC)
596
597 MESSAGE(" ")
598 if (DBUS_BUILD_TESTS)
599     message("NOTE: building with unit tests increases the size of the installed library and renders it insecure.")
600 endif(DBUS_BUILD_TESTS)
601
602 if (DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERT)
603     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)")
604 endif(DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERT)
605
606 if (DBUS_GCOV_ENABLED)
607     message("NOTE: building with coverage profiling is definitely for developers only.")
608 endif(DBUS_GCOV_ENABLED)
609
610 if (DBUS_ENABLE_VERBOSE_MODE)
611     message("NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance.")
612 endif(DBUS_ENABLE_VERBOSE_MODE)
613
614 if(NOT DBUS_DISABLE_ASSERT)
615     message("NOTE: building with assertions increases library size and decreases performance.")
616 endif(NOT DBUS_DISABLE_ASSERT)
617
618 if (DBUS_DISABLE_CHECKS)
619     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.")
620 endif(DBUS_DISABLE_CHECKS)
621
622 foreach(_note ${FOOTNOTES})
623     message(${_note})
624 endforeach()
625
626 MESSAGE(" ")
627
628 INCLUDE(modules/CPackInstallConfig.cmake)
629
630 add_custom_target(help-options
631     cmake -LH 
632     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
633 )