[CMake] debugging CMAKE_PREFIX_PATH

Konstantin Tokarev annulen at yandex.ru
Tue Sep 12 09:37:08 EDT 2017



12.09.2017, 16:31, "Zakrzewski, Jakub" <jakub.zakrzewski at scheer-group.com>:
> Hi,
>
>>  find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED)
>
>>  I build with -DCMAKE_PREFIX_PATH set, and in CMakeCache.txt, I see:
>
>>  //No help, variable specified on the command line.
>>  CMAKE_PREFIX_PATH:PATH=/usr/pkg/qt5
>
>>  //The directory containing a CMake configuration file for Qt5Core.
>>  Qt5Core_DIR:PATH=Qt5Core_DIR-NOTFOUND
>
>>  # ls /usr/pkg/qt5/lib/cmake/Qt5Core/Qt5CoreConfig.cmake
>>  /usr/pkg/qt5/lib/cmake/Qt5Core/Qt5CoreConfig.cmake
>
>>  so AFAICT, Qt5CoreConfig.cmake should be found.
>
>>  What am I missing?
>
> according to the documentation: https://cmake.org/cmake/help/v3.0/command/find_package.html
> you're using the find_package() in MODULE mode, so it tries to locate a FindQt5Core.cmake.
>
> Use this:
> find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED CONFIG)
>
> and it should do what you want.

This statement is wrong, when no MODULE or CONFIG are specified, CMake tries both, so find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED) is a correct way.

What actually happens here: rogue CMake project overwrites user-supplied CMAKE_PREFIX_PATH with its own value, so it is disregarded.

As a workaround (without changing project), you can pass -DQt5Core_DIR=/usr/pkg/qt5/lib/cmake/Qt5Core

>
> --
> Grüsse,
> Jakub
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake

-- 
Regards,
Konstantin


More information about the CMake mailing list