Reputation: 1775
I have the following block in my CMakeLists.txt for years since couple of applications have dependency on an old third party 32bit library.
IF("${CMAKE_VS_PLATFORM_NAME}" MATCHES "Win32")
# Build 32bit stuff
ELSE()
# Build 64bit stuff
ENDIF()
Yesterday, I upgraded from VS15 to VS17. However, I still need to keep some of the older apps in v140 toolset. At first I couldn't even build the configuration for v140 since it couldn't find the MSBuild.exe, so I had install build tools for VS17. I also need to specify the toolset v140/v141 while running the configuration.
Now everything works fine, except CMAKE_VS_PLATFORM_NAME now returns blank whether the toolset is v140 ot v141. So it always goes to ELSE() block in the CMAKE code to build 64bit. How do I retrieve the platform name now?
Upvotes: 0
Views: 1219
Reputation: 1775
Ok, I finally figured it out.
message(STATUS "${CMAKE_VS_PLATFORM_NAME}")
project (TestProject)
message(STATUS "${CMAKE_VS_PLATFORM_NAME}")
The first message command prints blank. The second one prints x64. It has a value only after the project name is defined.
Upvotes: 1