ycm-cmake-modules icon indicating copy to clipboard operation
ycm-cmake-modules copied to clipboard

FindLibOVR always selects the 32bit version of the Oculus SDK on Visual Studio 16 2019

Open S-Dafarra opened this issue 5 years ago • 4 comments

FindLibOVR detects the SDK version to be used by using CMAKE_GENERATOR_PLATFORM https://github.com/robotology/ycm/blob/32e544488537e435d61ffe237bb72f3908552c9c/find-modules/FindLibOVR.cmake#L55

On Visual Studio 16 2019 this variable is not set, thus defaulting to the 32bit version.

@traversaro

S-Dafarra avatar Aug 27 '20 08:08 S-Dafarra

Related comment:

From Visual Studio 16 2019, if CMAKE_GENERATOR_PLATFORM is not specified, CMake defaults to x64, while before it was default to Win32, so for Visual Studio <= 2017 the logic is actually valid, but it is broken for VS 2019. A quick fix is just to invoke the CMake of the superbuild or of YARP with the -A x64 option, that explicitly sets the CMAKE_GENERATOR_PLATFORM to x64. A proper fix is to check CMAKE_SIZEOF_VOID_P to know if we are targeting Windows 32-bit or 64-bit. This probably does not work correctly for cross-compilation (Windows on arm64, uwp, etc etc), but I guess that in any case the Oculus SDK is not available on those platforms.

traversaro avatar Aug 27 '20 08:08 traversaro

I'm not completely sure, but I don't think this is an issue of the module, if I understand correctly, CMAKE_GENERATOR_PLATFORM should be x64 when compiling for 64 bit windows, perhaps you are not actually building for x64? Or perhaps the CMAKE_VS_PLATFORM_NAME variable should be considered instead? (Adding also a link to CMAKE_GENERATOR for reference)

@traversaro can you add a link to the "Related comment" above?

drdanz avatar Aug 31 '20 16:08 drdanz

CMAKE_GENERATOR_PLATFORM should be x64 when compiling for 64 bit windows, perhaps you are not actually building for x64?

I did the same assumption, but the key docs is:

Generator-specific target platform specification provided by user.

If the user does not specify anything (i.e. the default generator is used) then the property is empty. So defaulting to 32-bit is ok for VS <= 2017, but not for VS2019 whose CMake generator defaults depend on the host platform, see https://cmake.org/cmake/help/latest/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.html#cmake-vs-platform-name-default . Probably using CMAKE_VS_PLATFORM_NAME is indeed the correct way to proceed.

traversaro avatar Sep 02 '20 20:09 traversaro

@traversaro can you add a link to the "Related comment" above?

The related comment is the one that I copied, is just something that I copied from a private issue tracker.

traversaro avatar Sep 02 '20 20:09 traversaro