CMake and ksysguardd

Alexander Neundorf neundorf at kde.org
Thu Oct 1 19:54:38 BST 2009


Hi John,

On Wednesday 30 September 2009, Alexander Neundorf wrote:
> On Wednesday 30 September 2009, John Tapsell wrote:
> > 2009/9/29 Pau Garcia i Quiles <pgquiles at elpauer.org>:
> > ..
> >
> > >>  Could anyone that knows CMake help me with this :)
> > >
> > > It is not difficult to make it compile without KDE. The attached patch
> > > fixes and/or ignores the issues I pointed above.
> >
> > It looks good.  How does this interact now with when people compile
> > kdebase? You still want "make install"  for example to install
> > ksysguardd. It's not important for "make install" to work if you run that
> > just inside the ksysguardd directory, if that helps.
> >
> > > We could use an #ifdef or alike to be able to build ksysguardd with
> > > KDE (using config-workspace, etc) and without KDE (ignoring it). Would
> > > that be interesting for you ?
> >
> > I don't know - is it important to use config-workspace?
>
> Go through the #defines in that file and find out which one(s) is/are used
> by ksysguardd.
> Then maybe do the same check in ksysguardd/CMakeLists.txt and put the
> result into config-ksysguardd.h.
>
> At the top of ksysguardd/CMakeLists.txt you could do:
>
> if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
>    # if we get here, ksysguard is built independent from the rest of
> kdebase include(ksysguardd-separate.cmake)
> endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
>
> and put everything you need into this ksysguardd-separate.cmake (or how you
> want to call it) file.
> Which could be more or less:
>
> -----------8<---------------8<---------------8<---------
> # Set INSTALL_TARGETS_DEFAULT_ARGS to something useful:
> set(INSTALL_TARGETS_DEFAULT_ARGS  RUNTIME DESTINATION bin
>                                   LIBRARY DESTINATION lib
>                                   ARCHIVE DESTINATION lib)
>
> ####### copied from kdelibs/cmake/modules/KDE4Defaults.cmake:
>
> # Always include srcdir and builddir in include path
> # This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
> in about every subdir
> # since cmake 2.4.0
> set(CMAKE_INCLUDE_CURRENT_DIR ON)
>
> # put the include dirs which are in the source or build tree
> # before all other include dirs, so the headers in the sources
> # are prefered over the already installed ones
> # since cmake 2.4.1
> set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
>
> ######### copy the contents of the three macros here:
>
> macro(MACRO_BOOL_TO_01 ...)
> ...
> endmacro(...)
> ...
>
> ######### and you may put a simplistic kde4_add_library() here too:
>
> macro(KDE4_ADD_LIBRARY)
>    add_library(${ARGN})
> endmacro(KDE4_ADD_LIBRARY)
>
>
> This way you will have only minor changes to the CMakeLists.txt, and all
> the things necessary to make it build separately are contained in just one
> file.

attached you can find a patch against current svn which makes building it 
separately possible.

There are only two issues left:
* FindSensors.cmake is in workspace/cmake/modules/, and CMAKE_MODULE_PATH is 
now set in KSysgardd-Separate.cmake accordingly. Since this file is used only 
in ksysguardd/, I would not object moving this file directly to 
workspace/ksysguard/ksysguardd/.

* You have to take care of config-workspace.h.
I.e. check what from that file is used in ksysguardd/, and put these checks 
into KSysgardd-Separate.cmake, which should then generate the results into 
config-ksysguardd.h. Then remove the usage of config-workspace.h.

If you do these two things, you can build ksysguardd cleanly as part of 
kdebase and also separate.
If you have questions, I'm happy to help.

Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ksysguardd-separate.patch
Type: text/x-diff
Size: 3680 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20091001/d4d81701/attachment.patch>


More information about the kde-core-devel mailing list