Michael Jansen info at michael-jansen.biz
Mon Aug 16 01:23:50 CEST 2010

>>> Then either specify CMAKE_PREFIX_PATH for fix the FindKTorrent.cmake
>>> module.
>> Cmake looks for FindKTorrent in CMAKE_MODULE_PATH, not CMAKE_PREFIX_PATH.
> Right. So where is the problem? FindKTorrent.cmake should either be part
> of cmake itself, part of kdelibs or be part of kdenetwork. Anything else
> is a bug (ktorrent shouldn't install a FindKTorrent.cmake that doesn't
> make any sense). As far as I can neither of the three is a case, so I
> suggest to add a proper FindKTorrent.cmake to kdenetwork/cmake/modules/.
> Then you can use CMAKE_PREFIX_PATH to help that Find-Module find
> ktorrent.

But we need the CMAKE_PREFIX_PATH -> CMAKE_MODULE_PATH anyway if you ask
me. It's what i would expect anyway and it would help preventing
problems like the one described below.

I tried to post the following message to the cmake list but i am pretty
unable to get an email there.

After reading the find_package documentation and thinking about how to
make my packages findable by cmake i have some question.

I initially thought the FindXYZ.cmake approach (called "Module" mode in
the documentation was dead after reading about the "Config" mode. Hey i
thought. That's great. Just install appropriate
<lower-case-name>-config.cmake" files in an appropriate place and be
done with it.

Then i read "Much of the interface is provided for completeness and for
use internally by find-modules loaded by Module mode.". Then i was
confused, did some testing and now i see some problems.

Let's for example have a look at the qjson module. That's not meant to
bash them but only to show that what i talk about are real problems.
There are currently three ways to find it.

1. kdelibs provides a FindQJson.cmake module. This will be used if i do
"find_package(QJson)". It uses pkgconfig to find qjson.

2. qjson provides a FindQJSON.cmake module. This will be used if i do
"find_package(QJSON).  It uses pkgconfig to find qjson.

So 1. and 2. will most likely find the same and working version of qjson.
Given a correct PKG_CONFIG_PATH variable it will only return a working
qjson package in regard to 64/32 bit. Exactly what i want.

3. qjson installs two file called qjson-config-version.cmake and qjson-

If i understand the cmake documentation correctly that is exactly the
way to go. We should only change 2. to use 3. to find qjson internally.

But these two files will be found if anyone use a
find_package(QjSon|qjson|or any other
upper/lowercase combination not matching 1 or 2) because of this part of
cmake behaviour:

The command searches for a file called "<name>Config.cmake" or
"<lower-case-name>-config.cmake" for each name specified.


CMake constructs a set of possible installation prefixes for the
package. Under each prefix several directories are searched for a
configuration file. The tables below show the directories searched.
Each entry is meant for installation trees following Windows (W), UNIX
(U), or Apple (A) conventions.

  <prefix>/                                                 (W)
  <prefix>/(cmake|CMake)/                                 (W)
  <prefix>/<name>*/                                       (W)
  <prefix>/<name>*/(cmake|CMake)/                         (W)
  <prefix>/(share|lib)/cmake/<name>*/                     (U)
  <prefix>/(share|lib)/<name>*/                           (U)
  <prefix>/(share|lib)/<name>*/(cmake|CMake)/             (U)

What is not mentioned here that it looks in lib64 (If
FIND_LIBRARY_USE_LIB64_PATH is set) to. The lib64 is optional, the lib
not. On OpenSuse here lib64 is for 64bit and lib
for 32bit. So even if i develop 64bit Software i can't make cmake ignore
lib/. Whatever it finds there won't suit me. That's why we probably need
a FindQJson.cmake file. To only search in
appropriate places for Config Files.

And now to the problem. A find_package( qjson ) will work for some and
not for others. And that is the same for all packages using the all
lowercase name for their config.cmake files.

If i am right i would consider the all lowercase names harmful.

And another note. It's even trickier because the Module mode does
completely ignore CMAKE_PREFIX_PATH and therefore does not find a
<prefix>[...]/module/FindQJSON.cmake but the Config mode looks under

A project like QJSON that tries to install a FindQJSON.cmake (however
useful that is) misleads it's users therefore. They perhaps only set
CMAKE_PREFIX_PATH, add a find_package(QJSON) and run cmake. It
works. Sometimes. But only using the config mode. Because they would
have to set CMAKE_MODULE_PATH too. And only as long as they don't
install some 32-bit development version of qjson.

This is all probably a theoritical problem with not much practical
relevance but i thought i would inquire anyway.


> Andreas

More information about the Kde-buildsystem mailing list