# how to understand the PlatformName in CMake

**URL:** <https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867>\
**Category:** Code\
**Created:** [June 15, 2022, 3:01am UTC](https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867 "2022-06-15T03:01:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhang-qiang-github](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhang-qiang-github/32/1913_2.png) [@zhang-qiang-github](https://discourse.cmake.org/u/zhang-qiang-github)\
**Post date:** [June 15, 2022, 3:01am UTC](https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867/1 "2022-06-15T03:01:32Z")

</div>

I want to generate myself package by CMake.

My CMakeLists.txt is:

```auto
...
set(Bin_Root "${CMAKE_CURRENT_SOURCE_DIR}/Bin/${PlatformName}")
set(Lib_Root "${CMAKE_CURRENT_SOURCE_DIR}/Lib/${PlatformName}")
install(TARGETS CommonCore
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
)
...

```

After building the project, INSTALL–\>Generate, and VS reports:

```auto
CMake Error at cmake_install.cmake: 54 (file):
  file INSTALL cannot find
  "xx/Bin/${PlatformName}/Debug/CommonCore.dll"
  No error.

```

Actually I can find the `CommonCore.dll` in `xx/Bin/x64/Debug`.

Then, I look into `cmake_install.cmake`, and it is:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/5/50e3808f7f4dd4c9e4b6c701322d7dbfa72b5bbf.png)

And I find the `cmake_install.cmake` in a successfully project, and it is:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/0/0b8a8ed004606a268775567d605d7a568de28fa6.png)

The only difference between the sucessfully&failed cmake\_install.cmake is that the successfully one do not include `PlatformName`.

The environment is:

```auto
system: win10 (sucessfully one), Windows Server 2019 Standard (failed one)
cmake: 3.22.1
vs: Community/Professional 20022 64 bit for sucessfully/failed one

```

Any suggestion is appreciated~~~

---

<div class="post-metadata">

**Author:** ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Post date:** [June 15, 2022, 3:53am UTC](https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867/2 "2022-06-15T03:53:43Z")

</div>

`PlatformName` is not a predefined variable in CMake. Maybe you want CMAKE\_SYSTEM\_NAME?

---

<div class="post-metadata">

**Author:** ![zhang-qiang-github](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhang-qiang-github/32/1913_2.png) [@zhang-qiang-github](https://discourse.cmake.org/u/zhang-qiang-github)\
**Post date:** [June 15, 2022, 10:55am UTC](https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867/3 "2022-06-15T10:55:41Z")

</div>

What I want is not `CMAKE_SYSTEM_NAME`. I want to know the platform, just like `x64/win32`.

`PlatformName` is not a predefined variable? But the following code would output the `dll` to `.../Bin/x64/Debug`

```auto
set(Bin_Root "${CMAKE_CURRENT_SOURCE_DIR}/Bin/${PlatformName}")
SET_TARGET_PROPERTIES(pA
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${Bin_Root}
)

```

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [June 15, 2022, 11:45am UTC](https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867/4 "2022-06-15T11:45:36Z")

</div>

> [@zhang-qiang-github](#):
>
> `PlatformName` is not a predefined variable? But the following code would output the `dll` to `.../Bin/x64/Debug`

So would this code:

```auto
set(Bin_Root "${CMAKE_CURRENT_SOURCE_DIR}/Bin/")
SET_TARGET_PROPERTIES(pA
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${Bin_Root}
)

```

`PlatformName` is most probably just not defined, thus expanding to an empty string.

---

<div class="post-metadata">

**Author:** ![zhang-qiang-github](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhang-qiang-github/32/1913_2.png) [@zhang-qiang-github](https://discourse.cmake.org/u/zhang-qiang-github)\
**Post date:** [June 16, 2022, 1:34am UTC](https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867/5 "2022-06-16T01:34:17Z")

</div>

Does CMake predefine any variable to indicate platform, like `x64/win32`?

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [June 16, 2022, 5:32am UTC](https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867/6 "2022-06-16T05:32:44Z")

</div>

I don’t think so but here’s a list of predefined variables: [https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html](https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html)

You may just have to compute that yourself based on other available information if you really need such names.

---

<div class="post-metadata">

**Author:** ![klirichek](https://discourse.cmake.org/user_avatar/discourse.cmake.org/klirichek/32/1657_2.png) [@klirichek](https://discourse.cmake.org/u/klirichek)\
**Post date:** [June 20, 2022, 6:06am UTC](https://discourse.cmake.org/t/how-to-understand-the-platformname-in-cmake/5867/7 "2022-06-20T06:06:25Z")

</div>

You can walk into CMakeFiles/X.XX.X subfolder of the binary dir after performing configure.  
There are set of files there, like CMakeSystem.cmake, CMakeCCompiler.cmake, etc. which defines variables available to you.  
For 64-bit Windows there are CMAKE\_C\_COMPILER\_ARCHITECTURE\_ID, MSVC\_C\_ARCHITECTURE\_ID, and same for CXX with value ‘x64’. You may choose appropriate (I think, preferable CMAKE\*).
