Cache variables from module

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

Cache variables from module

Florian Lindner
Hello,

I have a third party FindPETSc.cmake module:

https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake

The problem I have, is that variable PETSC_VERSION is not set when cmake is run for a second time

https://github.com/jedbrown/cmake-modules/issues/28

What is best way to deal with that?

Can an entire function be cached, e.g. petsc_get_version or is adding CACHE to the set calls of PETSC_VERSION the best way?

Adding CACHE INTERNAL gives me error messages:

set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}" CACHE INTERNAL "PETSc
version" PARENT_SCOPE)


CMake Error at tools/cmake-modules/FindPETSc.cmake:314 (if):
  if given arguments:

    "3.8.4" "CACHE" "INTERNAL" "PETSc version" "VERSION_LESS" "3.1"

  Unknown arguments specified



Thanks!
Florian
--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Cache variables from module

Isaiah Norton
PARENT_SCOPE and CACHE can't be used in the same call, presumably because cache is global. So cmake doesn't recognize those arguments, and instead sets the variable PETSC_VERSION to a list containing all the following arguments except PARENT_SCOPE (which does still apply). Perhaps a newer cmake version will give an error.
Try:

    set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}" CACHE INTERNAL "PETSc
version")

(possibly also with `FORCE`, though it probably doesn't make sense for a user to ever set that manually)

On Thu, May 3, 2018 at 3:36 AM, Florian Lindner <[hidden email]> wrote:
Hello,

I have a third party FindPETSc.cmake module:

https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake

The problem I have, is that variable PETSC_VERSION is not set when cmake is run for a second time

https://github.com/jedbrown/cmake-modules/issues/28

What is best way to deal with that?

Can an entire function be cached, e.g. petsc_get_version or is adding CACHE to the set calls of PETSC_VERSION the best way?

Adding CACHE INTERNAL gives me error messages:

set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}" CACHE INTERNAL "PETSc
version" PARENT_SCOPE)


CMake Error at tools/cmake-modules/FindPETSc.cmake:314 (if):
  if given arguments:

    "3.8.4" "CACHE" "INTERNAL" "PETSc version" "VERSION_LESS" "3.1"

  Unknown arguments specified



Thanks!
Florian
--

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:
https://cmake.org/mailman/listinfo/cmake


--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Cache variables from module

Isaiah Norton
Perhaps a newer cmake version will give an error.

Just tested with 3.11 -- sadly not. But the suggested fix does work.

On Thu, May 3, 2018 at 10:39 AM, Isaiah Norton <[hidden email]> wrote:
PARENT_SCOPE and CACHE can't be used in the same call, presumably because cache is global. So cmake doesn't recognize those arguments, and instead sets the variable PETSC_VERSION to a list containing all the following arguments except PARENT_SCOPE (which does still apply). Perhaps a newer cmake version will give an error.
Try:

    set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}" CACHE INTERNAL "PETSc
version")

(possibly also with `FORCE`, though it probably doesn't make sense for a user to ever set that manually)

On Thu, May 3, 2018 at 3:36 AM, Florian Lindner <[hidden email]> wrote:
Hello,

I have a third party FindPETSc.cmake module:

https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake

The problem I have, is that variable PETSC_VERSION is not set when cmake is run for a second time

https://github.com/jedbrown/cmake-modules/issues/28

What is best way to deal with that?

Can an entire function be cached, e.g. petsc_get_version or is adding CACHE to the set calls of PETSC_VERSION the best way?

Adding CACHE INTERNAL gives me error messages:

set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}" CACHE INTERNAL "PETSc
version" PARENT_SCOPE)


CMake Error at tools/cmake-modules/FindPETSc.cmake:314 (if):
  if given arguments:

    "3.8.4" "CACHE" "INTERNAL" "PETSc version" "VERSION_LESS" "3.1"

  Unknown arguments specified



Thanks!
Florian
--

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:
https://cmake.org/mailman/listinfo/cmake



--

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:
https://cmake.org/mailman/listinfo/cmake