how to understand the PlatformName in CMake

I want to generate myself package by CMake.

My CMakeLists.txt is:

...
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:

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:

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

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

The environment is:

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~~~

PlatformName is not a predefined variable in CMake. Maybe you want CMAKE_SYSTEM_NAME?

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

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

So would this code:

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.

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

I don’t think so but here’s a list of predefined variables: 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.

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*).