Question about functions

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

Question about functions

Steven Truppe
Hi everyone,

i have a function like:

FUNCTION(checksyste_64Bit arg1)

     IF(CMAKE_SIZEOF_VOID_P EQUAL 8)

         SET(${arg1} TRUE PARENT_SCOPE)

ENDFUNCTION()


but when i call it with an INTERNAL variable i've set before with

SET(SYSTEM_64BIT FALSE CACHE INTERNAL)

checksystem_64bit(${SYSTEM_64BIT})

the ${SYSTE_64BIT} variable stays the same, i thought when i use
PARENT_SCOPE on a variable i can change it's value from inside the
function ?


best regards!

--

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: Question about functions

Andreas Naumann
Am 18.02.19 um 20:43 schrieb [hidden email]:

> Hi everyone,
>
> i have a function like:
>
> FUNCTION(checksyste_64Bit arg1)
>
>     IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
>
>         SET(${arg1} TRUE PARENT_SCOPE)
>
> ENDFUNCTION()
>
>
> but when i call it with an INTERNAL variable i've set before with
>
> SET(SYSTEM_64BIT FALSE CACHE INTERNAL)
>
> checksystem_64bit(${SYSTEM_64BIT})
>
> the ${SYSTE_64BIT} variable stays the same, i thought when i use
> PARENT_SCOPE on a variable i can change it's value from inside the
> function ?
>
>
> best regards!
>
You should call your function without dollar and braces around the
variable, i.e.

   checksystem_64bit(SYSTEM_64BIT)

--

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