[CMake] InstallRequiredSystemLibraries fails for msvc10 x64

J Decker d3ck0r at gmail.com
Wed Mar 9 14:43:59 EST 2011


In InstallRequiredSystemLibraries

  IF(CMAKE_CL_64)
    SET(CMAKE_MSVC_ARCH amd64)
  ELSE(CMAKE_CL_64)
    SET(CMAKE_MSVC_ARCH x86)
  ENDIF(CMAKE_CL_64)


amd64 should be x64 for vs2010
    SET(CMAKE_MSVC_ARCH x64)

--------------------

If cmake is built as 64bit this won't work

    FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT
      PATHS
        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]/../../VC/redist"
        "${base_dir}/VC/redist"
      )

because that key is only installed as a 32 bit key (which is under
Wow6432Node with x64)

---------------------
This part is really confusing me - I really thought I had it , then I
tested a few other modes and it doesn't work.

Also, and I don't know why, but the following code works with vs2010
32bit, but not with vs2010 64bit

    FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT
      PATHS
        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]/../../VC/redist"
        "${base_dir}/VC/redist"
      )

the previous seems to work only in 32 bit mode... with x64 (other than
the arch change from amd64 to x64, it was still unable to locate the
redist, until I grabbed the value into a seperate variable....

Grabbing the registry value into a variable and then using that to
search works in 32 and 64 bit targets.  (actually after confirming
that it worked, the following doesn't actually work, but what's at the
end does)

Changing the search for the redist path like this works in all modes
32/64 debug/release....

    GET_FILENAME_COMPONENT( msvc_install_path
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]"
ABSOLUTE )
    FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT
      PATHS
        "${msvc_install_path}/../../VC/redist"
        "${base_dir}/VC/redist"
      )


More information about the CMake mailing list