README.cmake 7.32 KB
Newer Older
1 2 3 4
This file describes how to compile dbus using the cmake build system

Requirements
------------
5
- cmake version >= 2.6.0 see http://www.cmake.org
6 7 8
- installed libexpat see http://sourceforge.net/projects/expat/ 
    unsupported RelWithDebInfo builds could be fetched 
    from http://sourceforge.net/projects/kde-windows/files/expat/
9 10 11
- for generating documentation based on docbook files
    - xsltproc (provided by the distribution or from http://xmlsoft.org/XSLT/xsltproc2.html) and
    - docbook dtd and stylesheets (provided by the distribution or from https://sourceforge.net/projects/docbook/)
12 13 14 15

Building
--------

16 17
Win32 MinGW-w64|32
1. install mingw-w64 from http://sourceforge.net/projects/mingw-w64/
18
2. install cmake, libexpat and optional xsltproc and docbook dtd and stylesheets
19 20 21 22 23
3. get dbus sources
4. unpack dbus sources into a sub directory (referred as <dbus-src-root> later)
5. mkdir dbus-build
6. cd dbus-build
7. run 
24
    cmake -G "MinGW Makefiles" [<options, see below>] <dbus-src-root>
25 26
    mingw32-make
    mingw32-make install
27

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
Mingw32 cross compile on Linux
2. install cmake, libexpat and optional xsltproc and docbook dtd and stylesheets
    e.g on openSUSE Leap 15.0:
      sudo zypper ar -f https://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_15.0/
      sudo zypper install mingw32-cross-gcc-c++ mingw32-libexpat-devel libxslt-tools mingw32-docbook_4 mingw32-docbool-xsl-stylesheets
2. get dbus sources
3. unpack dbus sources into a sub directory (referred as <dbus-src-root> later)
4. mkdir dbus-build
5. cd dbus-build
6. run
    cmake -DCMAKE_TOOLCHAIN_FILE=<dbus-src-root>/cmake/i686-w64-mingw32.cmake \
          -DCMAKE_FIND_ROOT_PATH=/usr/i686-w64-mingw32/sysroot/i686-w64-mingw32 \
          [<options, see below>] <dbus-src-root>
    make
    make install

    Win32 Microsoft nmake
45
1. install MSVC 2010 Express Version from http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
46
2. install cmake, libexpat and optional xsltproc and docbook dtd and stylesheets
47 48 49 50 51
3. get dbus sources
4. unpack dbus sources into a sub directory (referred as <dbus-src-root> later)
5. mkdir dbus-build
6. cd dbus-build
7. run 
52
    cmake -G "NMake Makefiles" [<options, see below>] <dbus-src-root>
53 54
    nmake
    nmake install
55

56 57
Win32 Visual Studio 2010 Express IDE
1. install MSVC 2010 Express Version from http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
58
2. install cmake, libexpat and optional xsltproc and docbook dtd and stylesheets
59 60 61 62 63
3. get dbus sources
4. unpack dbus sources into a sub directory (referred as <dbus-src-root> later)
5. mkdir dbus-build
6. cd dbus-build
7. run
64
      cmake -G "Visual Studio 10" [<options, see below>] <dbus-src-root>
65
8a. open IDE with
66
      vcexpress dbus.sln
67
8b. for immediate build run
68 69
      vcexpress dbus.sln /build

70 71
Win32 Visual Studio 2010 Professional IDE
1. install MSVC 2010 Professional Version
72
2. install cmake, libexpat and optional xsltproc and docbook dtd and stylesheets
73 74 75 76 77
3. get dbus sources
4. unpack dbus sources into a sub directory (referred as <dbus-src-root> later)
5. mkdir dbus-build
6. cd dbus-build
7. run 
78
      cmake -G "Visual Studio 10" [<options, see below>] <dbus-src-root>
79
8a. open IDE with
80
      devenv dbus.sln
81
8b. for immediate build run
82
      devenv dbus.sln /build
83 84

Linux
85
2. install cmake, libexpat and optional xsltproc and docbook dtd and stylesheets
86 87 88 89 90
2. get dbus sources
3. unpack dbus sources into a sub directory (referred as <dbus-src-root> later)
4. mkdir dbus-build
5. cd dbus-build
6. run 
91
    cmake [<options, see below>] <dbus-src-root>
92 93 94 95
    make
    make install

For other compilers see cmake --help in the Generators section
96

97 98
Configuration flags
-------------------
99

100 101
When using the cmake build system the dbus-specific configuration flags that can be given 
to the cmake program are these (use -D<key>=<value> on command line). The listed values 
102
are the defaults (in a typical build - some are platform-specific).
103

104 105 106 107 108 109
// in case cmake is not able to determine the xsltproc executable (optional)
XSLTPROC_EXECUTABLE=<path to xsltproc executable)

// in case cmake is not able to determine the installation of the docbook stylesheets (optional)
DOCBOOKXSL_DIR=<path to docbook stylesheets)

110
// Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
CMAKE_BUILD_TYPE:STRING=Debug

// Include path for 3rdparty packages
CMAKE_INCLUDE_PATH:PATH=

// Library path for 3rdparty packages
CMAKE_LIBRARY_PATH:PATH=

// Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=C:/Program Files/dbus


// enable unit test code
DBUS_BUILD_TESTS:BOOL=ON

// The name of the dbus daemon executable
DBUS_DAEMON_NAME:STRING=dbus-daemon

// Disable assertion checking
131
DBUS_DISABLE_ASSERT:BOOL=OFF
132 133 134 135 136 137 138 139 140 141 142 143 144

// Disable public API sanity checking
DBUS_DISABLE_CHECKS:BOOL=OFF

// enable -ansi -pedantic gcc flags
DBUS_ENABLE_ANSI:BOOL=OFF

// build DOXYGEN documentation (requires Doxygen)
DBUS_ENABLE_DOXYGEN_DOCS:BOOL=OFF

// enable bus daemon usage statistics
DBUS_ENABLE_STATS:BOOL=OFF

145 146 147
// enable restricted servers for app containers
DBUS_ENABLE_CONTAINERS:BOOL=OFF

148 149 150 151 152 153 154 155 156
// support verbose debug mode
DBUS_ENABLE_VERBOSE_MODE:BOOL=ON

// build XML  documentation (requires xmlto or meinproc4)
DBUS_ENABLE_XML_DOCS:BOOL=ON

// install required system libraries
DBUS_INSTALL_SYSTEM_LIBS:BOOL=OFF

157 158 159 160 161
// session bus default listening address
DBUS_SESSION_BUS_LISTEN_ADDRESS:STRING=autolaunch:

// session bus fallback address for clients
DBUS_SESSION_BUS_CONNECT_ADDRESS:STRING=autolaunch:
162

163 164
// system bus default address (only useful on Unix)
DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket
165 166 167 168 169

win32 only:
// enable win32 debug port for message output
DBUS_USE_OUTPUT_DEBUG_STRING:BOOL=OFF

170 171 172
// use wine to run cross compiled test applications (only for cross compiling for Windows)
DBUS_USE_WINE:BOOL=OFF

173 174 175 176 177 178 179 180 181 182 183
gcc only:
// compile with coverage profiling instrumentation
DBUS_GCOV_ENABLED:BOOL=OFF

solaris only:
// enable console owner file 
HAVE_CONSOLE_OWNER_FILE:BOOL=ON

// Directory to check for console ownership
DBUS_CONSOLE_OWNER_FILE:STRING=/dev/console

184 185 186 187 188 189 190 191
// Linux only:
// enable inotify as dir watch backend
DBUS_BUS_ENABLE_INOTIFY:BOOL=ON

*BSD only:
// enable kqueue as dir watch backend
DBUS_BUS_ENABLE_KQUEUE:BOOL=ON

192 193 194 195
x11 only:
// Build with X11 auto launch support
DBUS_BUILD_X11:BOOL=ON

196 197 198 199
MSVC only (Visual Studio >= 2012):
// Enable code analyzing for MSVC compiler: /analyze
DBUS_MSVC_ANALYZE:BOOL=OFF

200 201 202
Note: Above mentioned options starting with DBUS_ or CMAKE_ could
be extracted after configuring from the output of running
"<maketool> help-options" in the build directory.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226


How to compile in dbus into clients with cmake
----------------------------------------------

To compile dbus library into a client application with cmake
the following cmake commands are required:

1. call find_package to find dbus package

find_package(DBus1)

2. after specifing targets link dbus into target

add_executable(test test.c)
target_link_libraries(test ${DBus1_LIBRARIES})

Adding ${DBus1_LIBRARIES} to targets also adds required dbus
include dirs and compiler definitions by default. There is
no need to add them with include_directories and add_definitions.

To compile against dbus installed in a non standard location
specify -DDBus1_DIR=<dbus-install-root>/lib[64]/cmake/DBus1
on cmake command line.