[CMake] Cache variables from module

Isaiah Norton isaiah.norton at gmail.com
Thu May 3 10:39:31 EDT 2018


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}.${PETS
C_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 <mailinglists at xgm.de> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180503/0b5b1c8f/attachment.html>


More information about the CMake mailing list