[CMake] VC2015 and Windows 7 compatibility

Elvis Stansvik elvis.stansvik at orexplore.com
Tue Sep 19 12:57:58 EDT 2017


2017-09-19 17:50 GMT+02:00 Gonzalo Garramuño <ggarra13 at gmail.com>:
> I compile on Windows 8.1.  I just found out that my program does not work on
> Windows 7 after I upgraded my toolchain to VC2015. Users of my program on
> Windows 7 get:
>
> Missing DLL ms-api-win-core-libraryloader-l1-2-0.dll
>
> After some digging, I found out that it can be because the use of SDK Sets
> on win8.1.  And that perhaps setting the compiler compatibility to WinXP
> should fix it.  However, I don't know how to do that from cmake.

I also build on Win 8.1/MSVC 2015, targeting Windows 7+, and what I do
is basically:

if(WIN32)
    add_definitions(/D_WIN32_WINNT=0x0601) # Target Windows 7+

    set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".")
    set(CMAKE_INSTALL_UCRT_LIBRARIES ON)
    include(InstallRequiredSystemLibraries)
endif()

The /D_WIN32_WINNT=0x0601 is what ensures Windows 7 compatibility and
CMAKE_INSTALL_UCRT_LIBRARIES is what ensures Universal CRT libraries
like the one you mentioned gets installed alongside the application.

You'll end up with a truckload of such small DLLs, but AFAIK this is
what you need to do if you want to do app-local deployment of the
Universal CRT.

Hope that helps.

Elvis

>
> Any ideas?
>
> If you want to see my CMakeLists.txt, you can get the code with:
>
> $ git clone ssh://ggarra13@git.code.sf.net/p/mrviewer/code mrviewer-code
>
>
> --
> Gonzalo Garramuño
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list