Strange commit to FindKDE4Internal.cmake

Pau Garcia i Quiles pgquiles at elpauer.org
Sun Feb 19 16:01:16 UTC 2012


On Sun, Feb 19, 2012 at 4:24 PM, Alexander Neundorf <neundorf at kde.org> wrote:

>> - A reference FindLibFoo.cmake is useful for developers who want to
>> make sure libfoo will be located on *any* platform, be it Linux,
>> Windows, Mac or something else. FooConfig.cmake is probably of little
>> use on Windows,
>
> Why do you think that ?

Because on Windows there are no standard paths to search for libraries
or anything, including FooConfig.cmake. See below for more.

>> which is why I, as a developer of TheGreatApp (an
>> application based on libfoo) would copy
>> /usr/share/doc/libfoo-dev/cmake/FindLibFoo.cmake to TheGreatApp/cmake,
>> add TheGreatApp/cmake to CMAKE_MODULE_PATH and use find_package(foo
>> REQUIRED). Especially if TheGreatApp is not a KDE application, which
>> has no reason to use or know about extra-cmake-modules.
>
> As written above, extra-cmake-modules is not intended to be in any way bound
> to KDE.
>
> Right now, for Qt5 you have to do
>
> find_package(Qt5 REQUIRED)
>
> Serious question: if you then get the following error message from cmake, what
> do you think is the problem ?
>
> CMake Error at CMakeLists.txt:3 (find_package):
>  Could not find module FindQt5.cmake or a configuration file for package
>  Qt5.
>
>  Adjust CMAKE_MODULE_PATH to find FindQt5.cmake or set Qt5_DIR to the
>  directory containing a CMake configuration file for Qt5.  The file will
>  have one of the following names:
>
>    Qt5Config.cmake
>    qt5-config.cmake
>
> -- Configuring incomplete, errors occurred!

That's exactly my point.

If TheGreatApp does a find_package(LibFoo REQUIRED) this is what happens:

- If LibFooConfig.cmake and/or FindLibFoo.cmake is available (either
from CMake itself or bundled with my *application* in
TheGreatApp/cmake), either LibFoo is found and all goes well, or
LibFoo is not found and the error the user will see is "LibFoo not
found" because either LibFooConfig.cmake or FindLibFoo.cmake would
provide what find_package needs (configuration and/or module).

- If LibFooConfig.cmake is installed on Windows but it's on a path
CMake does not look into (the *norm* on Windows), or if I do not
bundle FindLibFoo.cmake with my application, this is the error a user
would see on Windows: an incomprehensible error. Same error as if
LibFooConfig.cmake is not available.

I cannot see the advantage of LibFooConfig.cmake on non-Unix
platforms, or even on Unix platforms when libraries (including
FooConfig.cmake) is installed on non-standard locations. It will make
find_package fail at the very first step (trying to locate
FooConfig.cmake or FindLibFoo.cmake) without even delving into the
very finding operation.

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


More information about the Kde-buildsystem mailing list