CMake and ksysguardd

Alexander Neundorf neundorf at kde.org
Wed Sep 30 20:52:26 BST 2009


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.

Alex




More information about the kde-core-devel mailing list