Commit graph

65 commits

Author SHA1 Message Date
Ralf Habacker
f075650634 cmake: in macro generate_compiler_warning_flags prevent duplicates in variable containing unsupported warnings
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-04-21 13:51:55 +00:00
Ralf Habacker
fb5449e08f cmake: Fix detecting -Wformat-* warnings for gcc
gcc expects -Wformat to be set along with these type of warnings.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-04-21 13:51:55 +00:00
Ralf Habacker
bbd3f90a8d cmake: Fix not detecting unsupported g++ related warning checks
Unsupported warnings are detected by cmake through errors during
compilation, which causes g++ not to detect them, since they are
only output as warnings. Setting -Werror ensures this.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-04-21 13:51:55 +00:00
Alex Richardson
d35554c111 cmake: Only add warning flags if the compiler supports them
I am compiling for FreeBSD where the compiler is Clang and doesn't accept
all the GCC warning flags. This breaks the -Werror build:
```
error: unknown warning option '-Wduplicated-branches' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wduplicated-cond' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wjump-misses-init' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wrestrict' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wunused-but-set-variable'; did you mean '-Wunused-const-variable'? [-Werror,-Wunknown-warning-option]
```

With this change we use check_{c,cxx}_compiler_flag to check if the flag
is supported before adding it. In the future this will allow adding
clang-specific warning flags to the list of warnings as well since they
will be ignored for GCC.
2022-03-29 12:21:46 +00:00
Ralf Habacker
667b153dce cmake: Make gcc builds use similar compiler warnings to autotools
Fixes #356
2021-12-10 13:36:28 +00:00
Ralf Habacker
dccd628321 cmake: fix find_package related naming mismatch for GLIB2
The package name passed to `find_package_handle_standard_args` (GLIB2) did not match the name of the calling package (GLib2).
This could lead to problems when calling code that expects `find_package`.
result variables (e.g. `_FOUND`) expect to follow a certain pattern.

fixes #319
2021-11-10 00:49:21 +01:00
Ralf Habacker
b76c46437e cmake: add macro add_unit_test to reduce code duplication
This macro is now used by add_test_executable and
add_session_test_executable.
2020-11-26 10:46:34 +01:00
Ralf Habacker
97bdefd4e2 cmake: Add support for systemd integration on Linux operating systems
Previously, only the Autotools build system could do this. This commit
includes most of the same features as in the Autotools build, although
not the user-session semantics, which will be added separately.

Systemd support is controlled by the cmake variable ENABLE_SYSTEMD, which can
have the values OFF, ON and AUTO, the latter enabling support by default if
the required libraries are available.

With WITH_SYSTEMD_SYSTEMUNITDIR a custom installation location can be specified.
If it is not specified, the related install path is determined from the installed
systemd package, if present.
2020-06-10 18:13:47 +00:00
Ralf Habacker
eb6d4a1439 cmake: Add macro check_auto_option() as an addition to add_auto_option()
check_auto_option() checks the values given to an auto-option and prints
a fatal error in case of invalid combinations.
2020-06-10 18:13:47 +00:00
Ralf Habacker
ab404c5ffb cmake: rename tristateoption() to add_auto_option() and make signature compatible to option() 2020-06-10 18:13:47 +00:00
Ralf Habacker
6e8d75834e Add support to generate the api documentation in Qt help format
Qt help files are used by Qt Creator and KDevelop, for example, to support
the development of Qt-based applications and libraries.

Generating api documentation in Qt help format is controlled by two
user specific options named --enable-qt-help and --with-qchdir (autotools)
and -DENABLE_QT_HELP and -DINSTALL_QCH_DIR (cmake).
2020-04-29 15:23:23 +00:00
Ralf Habacker
8ffe1b949c cmake: Fix attribute 'original file name' in shared dbus library file info on Windows
The 'original filename' attribute was 'libdbus-1-3}.dll' with an unwanted
curly bracket.
2020-02-19 23:41:08 +01:00
Ralf Habacker
904fa97a1b Remove obsolete parameter in end... cmake keywords 2019-01-24 09:07:27 +01:00
Ralf Habacker
81df96d103 Adjust indents of cmake build system files always to 4 spaces 2019-01-23 21:34:24 +01:00
Ralf Habacker
54800ede4e Remove obsolete parameter in end... cmake keywords 2019-01-23 21:34:24 +01:00
Ralf Habacker
382857a265 Remove spaces between cmake command and opening bracket 2019-01-23 21:34:24 +01:00
Ralf Habacker
592251948c Use lower case cmake keywords 2019-01-23 21:34:24 +01:00
Ralf Habacker
781afd86a3 Replace tabs by 4 spaces in cmake build system files 2019-01-23 21:34:24 +01:00
Ralf Habacker
58b3d6ff20 Remove trailing spaces in cmake related files 2019-01-23 21:34:24 +01:00
Ralf Habacker
a8e5e5c552 Add cmake macros add_executable_version_info and add_library_version_info
This helps to reduce duplicated code.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2019-01-22 09:58:27 +01:00
Ralf Habacker
3bf97922bd Move cmake related build system to top level
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2019-01-22 09:57:40 +01:00
Ralf Habacker
7f9eb9cea8 Make sure ctest on Windows uses the currently built dbus library
The ctest application is usually not installed in the dbus build
directory. If an older dbus library is contained in this path, it will
be used instead of the currently built one, which can lead to runtime
errors (e.g.: c0000139) if the internal dbus API differs.
2019-01-10 20:19:04 +01:00
Ralf Habacker
fb799c6fd3 In cmake use variables provided from GNUInstallDirs consequently
This is required to support a custom installation layout, e.g. the
KDE binary factory.
2018-12-21 19:55:07 +01:00
Ralf Habacker
578ea41d8c Add cmake support for session based test executables
This patch introduces a new cmake macro add_session_test_executable,
which uses dbus-run-session to start a dbus-daemon process with a
temporary session bus in the background and the desired client file.

add_session_test_executable requires additional environment variables
defined in the top level CMakeLists.txt.

Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/135
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2018-12-17 16:25:12 +01:00
Ralf Habacker
a9e25f06c8 Use prefined variables to setup environment in cmake macro add_test_executable
Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/135
2018-12-17 16:25:12 +01:00
Ralf Habacker
56171457fb Add new cmake configure option DBUS_USE_WINE
If this variable is set, ctest uses wine to run cross compiled
test applications. Otherwise, they are assumed to run on a native
Windows operating system.

The new cmake variables Z_DRIVE_IF_WINE and TEST_WRAPPER have been
added to support this function.
2018-12-06 09:18:27 +01:00
Ralf Habacker
0c0e7361ae Adds uac manifest to all executable test files to prevent the Windows 740 error when running
The case occurred during test-pending-call-dispatch. To avoid further
applications being affected in the future, the manifest is added to
all test applications.

Windows Error 740 is defined as 'The Requested Operation Requires Elevation'
2018-12-05 15:58:48 +01:00
Simon McVittie
cdcf3c04dd FindDocBookXSL.cmake: Add
Taken from
<https://github.com/KDE/kdoctools/blob/master/cmake/FindDocBookXSL.cmake>

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/237
2018-11-20 18:29:39 +00:00
Simon McVittie
4e3bfe0c97 cmake: Fold GObject detection into GLib detection
Everywhere that we want GLib, we also want GObject and GIO. Detecting
GLib and GIO but not GObject makes very little sense anyway, because
GIO depends on GObject.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105521
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2018-03-19 12:33:45 +00:00
Simon McVittie
83b439f7b4 cmake: Match AC_DEFINE more precisely, respecting [] quoting
The regular expression previously used here to select the second
comma-delimited argument won't work when we introduce an argument
containing a comma, which I need to do now. We can address this by
recognising Autoconf's quoting mechanism (which uses square
brackets).

This is not 100% right (it doesn't understand nested square brackets),
but it's good enough in practice.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Acked-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354
2017-11-06 14:07:21 +00:00
Ralf Habacker
b59ff3d223 Fix cmake 3.5 configure error on opening a non existant file
Previous cmake versions seemed to be more tolerant.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103015
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Simon McVittie <smcv@collabora.com>
2017-10-18 19:20:02 +02:00
Ralf Habacker
191da55a72 Use cmake build in timestamp function to generate the build time stamp
The recent implementation generates a timestamp containing eol on
linux hosts, which generates unparseable versioninfo.rc.

This commit raises the minimal required cmake version to 3.0.2.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103015
Reviewed-by: Simon McVittie <smcv@collabora.com>
2017-10-18 15:22:04 +02:00
Simon McVittie
6a6521746b unix: Condition Linux-specific abstract sockets on __linux__
This is nicer for cross-compiling, because AC_RUN_IFELSE can't work
there. In practice abstract sockets are supported on Linux since
2.2 (so, all relevant versions), and on no other platform; so it
seems futile to keep this complexity.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34905
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-09-29 14:04:57 +01:00
Simon McVittie
cc1ee6c39d test/dbus-daemon: Exercise the Peer interface
We have to skip the GetMachineId() part during build-time testing
if it wouldn't work - there is no guarantee that dbus has ever been
installed on the build system. However, we can insist on it during
installed-tests, if we make sure to complete the installation for the
Travis-CI build by running dbus-uuidgen.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101257
2017-06-08 17:00:38 +01:00
Simon McVittie
36fcd43005 Pass in DBUS_TEST_EXEC via environment, not hard-coded into binaries
This avoids "capturing" the build directory in the built binaries
when built with embedded tests, which is good for reproducible builds.
See <https://reproducible-builds.org/> for more information.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100692
2017-04-18 17:20:30 +01:00
Ralf Habacker
6a8d0ae586 Replace deprecated cmake install_ functions with related install(...) calls.
Reviewed-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99586
2017-01-30 17:47:35 +01:00
Simon McVittie
7486899331 Revert "Keep cmake gcc builds in sync with autotools warnings."
When reviewing this commit, I said

    Looks OK, although this is going to become impossible if we start
    using the externally-curated list of warnings from
    <https://www.gnu.org/software/autoconf-archive/ax_compiler_flags.html>,
    which I've been quite tempted to do.

That time has now come. I think it's more valuable to have comprehensive
warnings under our primary build system, Autotools, than to have
some fairly elaborate CMake scripting to pick up the same compiler
warnings in both build systems; the CMake build system is primarily
there to give us the ability to compile with MSVC, which has orthogonal
compiler warning options anyway.

This reverts commit 41427560af.

Signed-off-by: Simon McVittie <smcv@debian.org>
Acked-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-13 17:20:40 +01:00
Simon McVittie
c7f3df0271 Replace $DBUS_USE_TEST_BINARY with $DBUS_TEST_DBUS_LAUNCH
Instead of using $DBUS_USE_TEST_BINARY to control whether to use the
hard-coded test binary TEST_BUS_LAUNCH_BINARY, we can just use
$DBUS_TEST_DBUS_LAUNCH to control what we launch directly, as we
were already doing for $DBUS_TEST_DAEMON.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92899
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2016-02-12 15:26:23 +00:00
Ralf Habacker
41427560af Keep cmake gcc builds in sync with autotools warnings.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-02-11 23:26:50 +01:00
Ralf Habacker
15006d7d12 Refactored cmake part dealing with compiler warnings to use warnings identifier.
It is now possible to use msvc warnings identifiers
(e.g. '4114') or gcc warnings keys (e.g. 'pointer-sign').

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-02-11 23:26:50 +01:00
Ralf Habacker
93895bc3a5 Do not require binfmt support for running cross compiled test applications.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88966
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-02-08 23:16:23 +01:00
Simon McVittie
9c3034f125 cmake: run all automated tests with --tap for better diagnostics
For GLib-based tests it's useful, because it means g_test_message()
gets logged. For the embedded tests it's now accepted and ignored.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93194
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-12-02 00:53:00 +01:00
Ralf Habacker
d46f7bac0d cmake: @VAR@ substitutions in set() are deprecated, use string(CONFIGURE) instead (policy CMP0053)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89450
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-06 20:35:59 +01:00
Ralf Habacker
939b3d97ee Add check to cmake build system if config.h.cmake is in sync with autotools.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=85418
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-05 13:54:10 +01:00
Ralf Habacker
4d8a27701b Add cmake macro autoheaderchecks().
This macro prints out any include file defined as HAVE_..._H in the config
header template and not in the related cmake configure checks file.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=85418
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-05 13:52:57 +01:00
Ralf Habacker
dca6591fa2 Keep cmake defines GLIB_VERSION_... in sync with autotools.
This patch adds autotools related cmake macros autoinit() and autodefine().

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-03 16:37:32 +01:00
Ralf Habacker
ea1884e3e5 Keep cmake generated shared dbus-1 library file name in sync with autotools.
Autotools uses a versioned shared library name derived from libtool.
This patch adds a versioned shared library name to cmake builds for all
supported platforms. Binary compatibility for clients build against older
cmake generated binary packages of dbus is provided; on unix like os
with symbolic links and on Windows with a copy of the shared library.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=74117
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-01-30 17:09:41 +01:00
Ralf Habacker
c39722e286 Give cmake users some hints/requirements when cross compiling for Windows on Linux.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-01-21 21:09:55 +01:00
Simon McVittie
7457a44011 tests: don't block and wait for a debugger on abort
In general, I think developers running the tests would expect
them to terminate rather than hanging. Developers who want to debug
such an abort by attaching a debugger to a live process can still set
DBUS_BLOCK_ON_ABORT in the environment.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2014-01-10 01:36:16 +01:00
Ralf Habacker
8e728f36d1 Use macros for test and helper executable targets on cmake build system.
The new macros add_test_executables and add helper_executables provides a
platform independent way for specifing dbus test and service applications.

On native Windows and Linux/UNIX systems the test applications are
directly runable.

When cross compiling for Windows on Linux test applications could be
executed on the Linux host system with the help of wine and activated
binfmt_misc support for wine.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-01-10 01:24:56 +01:00