# powershell call cmake script, but some var it empty

**URL:** https://discourse.cmake.org/t/powershell-call-cmake-script-but-some-var-it-empty/12767
**Category:** Code
**Tags:** os:windows
**Created:** [October 12, 2024, 9:59am UTC](https://discourse.cmake.org/t/powershell-call-cmake-script-but-some-var-it-empty/12767 "2024-10-12T09:59:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)
#### Post date: [October 12, 2024, 9:59am UTC](https://discourse.cmake.org/t/powershell-call-cmake-script-but-some-var-it-empty/12767/1 "2024-10-12T09:59:54Z")

</div>

cmake -P install.cmake -DHELLO=“hello”

```auto
#install.cmake
echo "result: ${CMAKE_SYSTEM_NAME}" 
echo "result: ${HELLO}" 

```

```auto
#output
result:  
result:  

```

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [October 12, 2024, 12:00pm UTC](https://discourse.cmake.org/t/powershell-call-cmake-script-but-some-var-it-empty/12767/2 "2024-10-12T12:00:41Z")

</div>

Variable definitions (`-D` options) must be specified **before** the `-P` option.

I think variables describing the system are not available in script mode.

---

<div class="post-metadata">

### Author: ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)
#### Post date: [October 12, 2024, 2:35pm UTC](https://discourse.cmake.org/t/powershell-call-cmake-script-but-some-var-it-empty/12767/3 "2024-10-12T14:35:50Z")

</div>

> [@marc.chevrier](#):
>
> Variable definitions (`-D` options) must be specified **before** the `-P` option.

what is the command line?  
-P \<file\> = Process script mode.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [October 12, 2024, 3:32pm UTC](https://discourse.cmake.org/t/powershell-call-cmake-script-but-some-var-it-empty/12767/4 "2024-10-12T15:32:10Z")

</div>

As specified in the [documentation](https://cmake.org/cmake/help/latest/manual/cmake.1.html):

```auto
Run a Script
 cmake [-D <var>=<value>]... -P <cmake-script-file>

```
