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