how to pass a parameter to cmake using %cmake_kde4


I want to build a KDE4 package in OBS. I have to pass a parameter (type: “-D DISABLE_LIB_X_SUPPORT=YES”) to be able to run cmake sucessfull on older openSUSE versions who don’t provide the requiered lib.

However, I want to use %cmake_kde4 (and not call cmake directly) because the additional switches are good and I don’t want to hardcode the install directories etc.

It isn’t possible to write simply “%cmake_kde4 -D DISABLE_LIB_X_SUPPORT=YES” because this expands to something like “cmake -SWITCH1 -SWITCH2 ./ -D DISABLE_LIB_X_SUPPORT=YES” and has the target directory in the middle of the options, which is invalid.

So, is there a possibility to make use of the parameters of %cmake_kde4 and also pass my own parameters additionally?

ktorrent uses

%cmake_kde4 -d build -- -DENABLE_DHT_SUPPORT=false


Not that I understand why it works.

Hello RedDwarf.

That helps me a lot. Thanks.

The reason why it works for KTorrent is CMake. CMake accepts a call like


as valid while


(with a space after -D) is invalid. When you want to have a space after -D, you must put the option before the directory. When you don’t use a space, you can put it before the directory, but also after it.

So now I use %cmake_kde4 with parameter but without a space.

Thank you a lot.