Bug 61637 - cmake linux fixes
Summary: cmake linux fixes
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: Ralf Habacker
QA Contact: Simon McVittie
URL:
Whiteboard: review+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2013-02-28 21:35 UTC by Ralf Habacker
Modified: 2013-03-28 07:29 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Fixed CMake linux builds; they require rt library. (901 bytes, patch)
2013-02-28 21:38 UTC, Ralf Habacker
Details | Splinter Review
CMake linux fixes when using meinproc4 doc generator. (1.78 KB, patch)
2013-02-28 21:38 UTC, Ralf Habacker
Details | Splinter Review
Fix cmake linux build: dbus-1 and dbus-internal require to link to rt library (1.17 KB, patch)
2013-03-04 14:25 UTC, Ralf Habacker
Details | Splinter Review
Build log (3.16 KB, text/plain)
2013-03-27 18:53 UTC, Hrvoje Senjan
Details

Description Ralf Habacker 2013-02-28 21:35:00 UTC
With recent dbus source there are a few cmake fixes required for linux. Patches are located http://cgit.freedesktop.org/~rhabacker/dbus/log/ (last 2)
Comment 1 Ralf Habacker 2013-02-28 21:38:07 UTC
Created attachment 75712 [details] [review]
Fixed CMake linux builds; they require rt library.
Comment 2 Ralf Habacker 2013-02-28 21:38:50 UTC
Created attachment 75713 [details] [review]
CMake linux fixes when using meinproc4 doc generator.
Comment 3 Simon McVittie 2013-03-04 12:35:59 UTC
Comment on attachment 75712 [details] [review]
Fixed CMake linux builds; they require rt library.

Review of attachment 75712 [details] [review]:
-----------------------------------------------------------------

::: cmake/CMakeLists.txt
@@ +494,5 @@
>  endif  (DBUS_BUILD_TESTS)
>  
> +if (UNIX)
> +    set(DBUS_LIBRARIES dbus-1 rt)
> +    set(DBUS_INTERNAL_LIBRARIES dbus-internal rt)

No, this should never be necessary. Instead, use something like:

    target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT} rt)

for the non-WIN32 case in dbus/CMakeLists.txt.

(Strictly speaking, -lrt might be required, optional or broken, depending on platform... but I don't particularly care about CMake working on non-Linux Unix, which should use Autotools instead.)
Comment 4 Simon McVittie 2013-03-04 12:36:54 UTC
Comment on attachment 75713 [details] [review]
CMake linux fixes when using meinproc4 doc generator.

Review of attachment 75713 [details] [review]:
-----------------------------------------------------------------

Seems reasonable.
Comment 5 Ralf Habacker 2013-03-04 13:17:31 UTC
(In reply to comment #3)
> Comment on attachment 75712 [details] [review] [review]
> Fixed CMake linux builds; they require rt library.
> 
> Review of attachment 75712 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: cmake/CMakeLists.txt
> @@ +494,5 @@
> >  endif  (DBUS_BUILD_TESTS)
> >  
> > +if (UNIX)
> > +    set(DBUS_LIBRARIES dbus-1 rt)
> > +    set(DBUS_INTERNAL_LIBRARIES dbus-internal rt)
> 
> No, this should never be necessary. Instead, use something like:
> 
>     target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT} rt)
> 
> for the non-WIN32 case in dbus/CMakeLists.txt.
> 
This do not fix all cases: all targets in bus subdir using DBUS_INTERNAL_LIBRARIES needs rt too. 

I can add the following stuff to bus/CMakeLists.txt

IF (NOT WIN32)
    set(DBUS_INTERNAL_LIBRARIES "${DBUS_INTERNAL_LIBRARIES} rt")
endif ()
Comment 6 Simon McVittie 2013-03-04 13:37:03 UTC
(In reply to comment #5)
> >     target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT} rt)
>
> This do not fix all cases: all targets in bus subdir using
> DBUS_INTERNAL_LIBRARIES needs rt too. 

Sorry, yeah, I meant "what I said, and then the same again for dbus-internal".

The general design principle should be that the libraries used by any given static or shared library are an implementation detail of that static or shared library: if dbus-daemon directly uses dbus-internal and Expat, and dbus-internal uses pthreads and librt, it should be enough to say "link dbus-daemon against dbus-internal and Expat" and the build system should be clever enough to work out that it also needs pthreads and librt.

This appears to be true for pthreads - dbus-daemon does not explicitly link to ${CMAKE_THREAD_LIBS_INIT}, but it still works - so presumably CMake is clever enough to make this happen.

In the Autotools stack, it's libtool that is responsible for getting this right.
Comment 7 Ralf Habacker 2013-03-04 14:25:46 UTC
Created attachment 75898 [details] [review]
Fix cmake linux build: dbus-1 and dbus-internal require to link to rt library
Comment 8 Ralf Habacker 2013-03-04 14:26:30 UTC
(In reply to comment #6)

> This appears to be true for pthreads - dbus-daemon does not explicitly link
> to ${CMAKE_THREAD_LIBS_INIT}, but it still works - so presumably CMake is
> clever enough to make this happen.

yes, works as expected
Comment 9 Simon McVittie 2013-03-04 14:44:55 UTC
Comment on attachment 75898 [details] [review]
Fix cmake linux build: dbus-1 and dbus-internal require to link to rt library

Review of attachment 75898 [details] [review]:
-----------------------------------------------------------------

Thanks, ship it.
Comment 10 Ralf Habacker 2013-03-04 17:30:08 UTC
committed to master
Comment 11 Hrvoje Senjan 2013-03-27 18:53:08 UTC
Created attachment 77120 [details]
Build log

With the change, still fails to build on openSUSE. Attached the fail part
Comment 12 Ralf Habacker 2013-03-28 07:29:44 UTC
(In reply to comment #11)
> Created attachment 77120 [details]
> Build log
> 
> With the change, still fails to build on openSUSE. Attached the fail part

 libtool: link: gcc -Wall -Wextra -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align -Wno-address -Wfloat-equal -Wdeclaration-after-statement -Wno-unused-label -Wno-missing-field-initializers -Wno-unused-parameter -Wno-sign-compare -Wno-pointer-sign -Wno-type-limits -fno-common -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fno-strict-aliasing -fPIC -fpie -fstack-protector -pie -o dbus-daemon-launch-helper activation-helper-bin.o config-loader-expat.o config-parser-common.o config-parser-trivial.o desktop-file.o utils.o activation-helper.o  ../dbus/.libs/libdbus-internal.a -lsystemd-login -lsystemd-daemon -lexpat -lpthread

The build log shows that this is an autotools issue, that dbus-daemon-launch-helper could not be build and that there is no -rt library added to the link line.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.