MantisBT - CMake
View Issue Details
0016073CMakeModulespublic2016-04-21 03:382016-06-10 14:21
Lewoco 
Brad King 
normalminoralways
closedfixed 
MSVS2015Windows
CMake 3.5.2 
CMake 3.6CMake 3.6 
0016073: InstallRequiredSystemLibraries and VS 2015 Universal CRT libraries
Many system DLL's required by MSVS2015 are not identified by InstallRequiredSystemLibraries.
- add_executable a simple hello world
- Use InstallRequiredSystemLibraries to install the required libraries
- Build an installer using WiX (or whatever)
- Install it on Windows 7 (no updates)

BUG: executable cannot be run because of missing DLL's.

Note:
- Updates might have helped but I didn't try it.
- Probably also affects Windows 8/8.1.
- Might not affect Windows 10? (see link)

https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/ [^]
Right now I'm using the following code to select the additional required libraries. Please integrate something similar into InstallRequiredSystemLibraries:

# InstallRequiredSystemLibraries does not properly support MSVS 14 yet, so do it manually.
unset(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_DEBUG)
unset(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_RELEASE)
if(DEFINED MSVC_VERSION AND NOT MSVC_VERSION LESS 1900)
    # Internal: Architecture-appropriate library directory names.
    if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM")
        set(_winsdk_arch8 arm) # what the WDK for Win8+ calls this architecture
    else()
        if(CMAKE_SIZEOF_VOID_P MATCHES "8")
            set(_winsdk_arch8 x64) # what the WDK for Win8+ calls this architecture
        else()
            set(_winsdk_arch8 x86) # what the WDK for Win8+ calls this architecture
        endif()
    endif()

    # The CRT is distributed with MSVS.
    get_filename_component(MSVS_DIR
        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;ShellFolder]" ABSOLUTE)

    # As of MSVC 19 the CRT depends on the 'univeral' CRT (which is part of Windows development kit 10 and above).
    # http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx [^]
    get_filename_component(WINDOWS_KIT_DIR
        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE)

    file(GLOB CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_DEBUG
        "${MSVS_DIR}/VC/redist/debug_nonredist/${_winsdk_arch8}/Microsoft.VC140.DebugCRT/*.dll"
        "${WINDOWS_KIT_DIR}/Redist/ucrt/DLLs/${_winsdk_arch8}/api-ms-win-*.dll"
        "${WINDOWS_KIT_DIR}/bin/${_winsdk_arch8}/ucrt/*.dll"
    )
    file(GLOB CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_RELEASE
        "${MSVS_DIR}/VC/redist/${_winsdk_arch8}/Microsoft.VC140.CRT/*.dll"
        "${WINDOWS_KIT_DIR}/Redist/ucrt/DLLs/${_winsdk_arch8}/*.dll"
    )
endif()
No tags attached.
related to 0015552closed Brad King InstallRequiredSystemLibraries needs to learn about VS 2015 
related to 0015691closed Brad King BundleUtilities broken on Win10 (MSVC 2015) 
Issue History
2016-04-21 03:38LewocoNew Issue
2016-04-21 03:58Nils GladitzRelationship addedduplicate of 0015552
2016-04-21 08:04Brad KingRelationship addedrelated to 0015691
2016-04-21 08:09Brad KingNote Added: 0040904
2016-04-21 08:09Brad KingRelationship replacedrelated to 0015552
2016-04-21 08:10Brad KingSummaryInstallRequiredSystemLibraries needs updating for MSVS2015 => InstallRequiredSystemLibraries and VS 2015 Universal CRT libraries
2016-04-21 22:28LewocoNote Added: 0040920
2016-04-21 22:32LewocoNote Edited: 0040920bug_revision_view_page.php?bugnote_id=40920#r2092
2016-05-02 15:40Brad KingNote Added: 0041012
2016-05-12 10:12Tavi CacinaNote Added: 0041060
2016-05-12 11:14Brad KingNote Added: 0041061
2016-05-12 11:14Brad KingAssigned To => Brad King
2016-05-12 11:14Brad KingStatusnew => resolved
2016-05-12 11:14Brad KingResolutionopen => fixed
2016-05-12 11:14Brad KingFixed in Version => CMake 3.6
2016-05-12 11:14Brad KingTarget Version => CMake 3.6
2016-06-10 14:21Kitware RobotNote Added: 0041173
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040904)
Brad King   
2016-04-21 08:09   
See 0015552:0038714 and the change linked from it. I think that takes care of the non-UCRT part.

IIRC originally Microsoft intended for the UCRT to be deployed only via Windows Update. That was the known state as of 0015552:0038714. When that proved impractical MS changed its stance to allow application installers to deploy it too. However, IIUC the UCRT DLLs should not be placed next to application binaries as InstallRequiredSystemLibraries does, but instead installed as a system package.

Gilles?
(0040920)
Lewoco   
2016-04-21 22:28   
(edited on: 2016-04-21 22:32)
Windows updates are not an acceptable replacement for application-specific deployment. Installation of Windows updates requires administrative privileges which rules them out for any type of deployment that is usable without adminstrative privileges. Since very few applications require administrative privileges it is fair to say that relying on Windows updates is impractical for all but a few applications that already require administrative privileges for some other reason.

To put this in other words, if you rely on Windows updates to deploy the UCRT you are probably making your installer unnecessarily brittle: Either it will (probably needlessly) require administrative privileges to install or it will not work on many machines that don't already happen to have the updates installed.

(0041012)
Brad King   
2016-05-02 15:40   
Re 0016073:0040920: I'm not saying that users should use Windows Update. I was simply explaining my understanding of the history of Microsoft's policy on how the UCRT should be deployed.

What remains is to understand exactly how MS suggests deployment should be done, in particular when we cannot have admin access to the target machine. Also, we need to know exactly what files should be deployed for the UCRT.
(0041060)
Tavi Cacina   
2016-05-12 10:12   
They specify which files should be deployed for the UCRT. See the 6th point from "Distributing Software that uses the Universal CRT": https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/ [^]

"6. Updated September 11, 2015: App-local deployment of the Universal CRT is supported. To obtain the binaries for app-local deployment, install the Windows Software Development Kit (SDK) for Windows 10. The binaries will be installed to C:\Program Files (x86)\Windows Kits\10\Redist\ucrt. You will need to copy all of the DLLs with your app (note that the set of DLLs are necessary is different on different versions of Windows, so you must include all of the DLLs in order for your program to run on all supported versions of Windows)."
(0041061)
Brad King   
2016-05-12 11:14   
Re 0016073:0041060: Thanks.

I've implemented the UCRT installation option:

 InstallRequiredSystemLibraries: Optionally install Windows UCRT
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6b0b0660 [^]
(0041173)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.