debugging CMAKE_PREFIX_PATH

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

debugging CMAKE_PREFIX_PATH

Patrick Welche
I am trying to build a package which has in its CMakeLists.txt:

set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED)

(It may be that QT_PREFIX is not set?)

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?

Cheers,

Patrick
--

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
Reply | Threaded
Open this post in threaded view
|

Re: debugging CMAKE_PREFIX_PATH

Zakrzewski, Jakub

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.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: debugging CMAKE_PREFIX_PATH

Konstantin Tokarev


12.09.2017, 16:31, "Zakrzewski, Jakub" <[hidden email]>:

> 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
--

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
Reply | Threaded
Open this post in threaded view
|

Re: debugging CMAKE_PREFIX_PATH

Patrick Welche
Problematic (scribus) CMakeLists.txt:

  set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake")
  set(CMAKE_INCLUDE_CURRENT_DIR ON)
  find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED)

On Tue, Sep 12, 2017 at 04:37:08PM +0300, Konstantin Tokarev wrote:
> 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

Thank you! I had found the workaround, but the list of Qt packages
was becoming rather long. Getting rid of the CMAKE_PREFIX_PATH
over-ride fixed things, but then revealed a further problem:

  set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
  set(CAIRO_DIR ${CMAKE_MODULE_PATH})
  find_package(CAIRO REQUIRED)

  $ ls -1 CMakeLists.txt cmake/modules/CAIROConfig.cmake
  CMakeLists.txt
  cmake/modules/CAIROConfig.cmake

Any thoughts on this variation on the theme?


Cheers,

Patrick
--

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
Reply | Threaded
Open this post in threaded view
|

Re: debugging CMAKE_PREFIX_PATH

Patrick Welche
On Tue, Sep 12, 2017 at 11:52:00PM +0100, Patrick Welche wrote:

> Problematic (scribus) CMakeLists.txt:
>
>   set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake")
>   set(CMAKE_INCLUDE_CURRENT_DIR ON)
>   find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED)
>
> On Tue, Sep 12, 2017 at 04:37:08PM +0300, Konstantin Tokarev wrote:
> > 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
>
> Thank you! I had found the workaround, but the list of Qt packages
> was becoming rather long. Getting rid of the CMAKE_PREFIX_PATH
> over-ride fixed things, but then revealed a further problem:
>
>   set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
>   set(CAIRO_DIR ${CMAKE_MODULE_PATH})
>   find_package(CAIRO REQUIRED)
>
>   $ ls -1 CMakeLists.txt cmake/modules/CAIROConfig.cmake
>   CMakeLists.txt
>   cmake/modules/CAIROConfig.cmake

Actually, there is more to this: the build system alters the above to:

set (CMAKE_MODULE_PATH "/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules" "${CMAKE_SOURCE_DIR}/cmake/modules")

AFAICT CMAKE_MODULE_PATH should end up as dir1;dir2, but the CMakeCache.txt
says:

CMAKE_MODULE_PATH:PATH=/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules

so only one argument to set() made it?

Cheers,

Patrick
--

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
Reply | Threaded
Open this post in threaded view
|

Re: debugging CMAKE_PREFIX_PATH

Patrick Welche
I think I am confused by the following:

1) CMAKE_PREFIX_PATH;

Problematic (scribus) CMakeLists.txt:  

   set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake")

CMakeCache.txt:

  //No help, variable specified on the command line.
  CMAKE_PREFIX_PATH:PATH=/usr/pkg/qt5

So the problem was that CMakeLists.txt overwrote the command line.
Removing the set() line made things work

2) CMAKE_MODULE_PATH

CMakeLists.txt (with extras to debug):

  set (CMAKE_MODULE_PATH "/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules" "one" "two" "/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules" "${CMAKE_SOURCE_DIR}/cmake/modules")
  set(testpath ${CMAKE_MODULE_PATH} CACHE PATH "testing path")

CMakeCache.txt:

  //No help, variable specified on the command line.
  CMAKE_MODULE_PATH:PATH=/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules

  //testing path
  testpath:PATH=/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules;one;two;/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules;/usr/obj/pkgsrc/print/scribus5/work.x86_64/scribus-1.5.3/cmake/modules

So here, it seems the command line overwrites CMakeLists.txt ?!

Cheers,

Patrick
--

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
Reply | Threaded
Open this post in threaded view
|

Re: debugging CMAKE_PREFIX_PATH

Alexander Neundorf-3
On 2017 M09 13, Wed 09:50:48 CEST Patrick Welche wrote:
> I think I am confused by the following:
>
> 1) CMAKE_PREFIX_PATH;
>
> Problematic (scribus) CMakeLists.txt:
>
>    set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake")

This looks wrong to me.
In general CMAKE_PREFIX_PATH should contain only the base install directory of
packages, and not point into the library dir etc. So it should more look
something like this:

 set(CMAKE_PREFIX_PATH "${QT_PREFIX}")

But actually this should be left to the user, since he knows where Qt is used
(or is supposed to know).

> CMakeCache.txt:
>
>   //No help, variable specified on the command line.
>   CMAKE_PREFIX_PATH:PATH=/usr/pkg/qt5
>
> So the problem was that CMakeLists.txt overwrote the command line.
> Removing the set() line made things work

Yes. A "normal" set() call overrides values coming from the cache.

> 2) CMAKE_MODULE_PATH
>
> CMakeLists.txt (with extras to debug):
>
>   set (CMAKE_MODULE_PATH
> "/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules" "one"
> "two" "/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-Modules"
> "${CMAKE_SOURCE_DIR}/cmake/modules") set(testpath ${CMAKE_MODULE_PATH}
> CACHE PATH "testing path")
>
> CMakeCache.txt:
>
>   //No help, variable specified on the command line.
>  
> CMAKE_MODULE_PATH:PATH=/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlin
> k/cmake-Modules
>
>   //testing path
>  
> testpath:PATH=/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-M
> odules;one;two;/usr/obj/pkgsrc/print/scribus5/work.x86_64/.buildlink/cmake-M
> odules;/usr/obj/pkgsrc/print/scribus5/work.x86_64/scribus-1.5.3/cmake/module
> s
>
> So here, it seems the command line overwrites CMakeLists.txt ?!

Ehm, doesn't testpath in the CMakeCache.txt have the contents of
CMAKE_MODULE_PATH from the CMakeLists.txt ?

Alex

--

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