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