[CMake] How to Switch to Static Runtime on Command Line?

Eric Doenges doenges at mvtec.com
Mon Oct 28 08:23:09 EDT 2019


I think it is worth adding to what Mateusz wrote that the 
MSVC_RUNTIME_LIBRARY property / CMAKE_MSVC_RUNTIME_LIBRARY variable are 
only available if policy CMP0091 is set to NEW, which it will not be 
because LLVM's CMakeLists.txt only requires CMake 3.4.3 or later (and 
thus all policies introduced after 3.4.3 are set to OLD for 
compatibility). So if you do not want to edit LLVM's CMakeLists.txt, you 
need to use the options provided by LLVM's CMake project to control the 
build.

We select the CRT LLVM's libraries will use with the LLVM_USE_CRT_DEBUG 
and LLVM_USE_CRT_RELEASE options, i.e. to build with a static MSVC 
runtime we use

-DLLVM_USE_CRT_DEBUG=MTd -DLLVM_USE_CRT_RELEASE=MT

These options are not documented on the "Building LLVM with CMake" page, 
but can be found by looking into LLVM's cmake directory.

Am 28.10.19 um 12:53 schrieb Mateusz Loskot:
> On Mon, 28 Oct 2019 at 12:22, Osman Zakir <osmanzakir90 at hotmail.com> wrote:
>> And I should do "-DCMAKE_MSVC_RUNTIME_LIBRARY=/MT"
> Man, read the docs I pasted!!!
> https://cmake.org/cmake/help/v3.15/prop_tgt/MSVC_RUNTIME_LIBRARY.html
>
> Best regards,
-- 

*Dr. Eric Dönges*
Senior Software Engineer

MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
doenges at mvtec.com <mailto:mustermann at mvtec.com> | Tel: +49 89 457 695-0 
| www.mvtec.com <http://www.mvtec.com>

Find our privacy policy here <https://www.mvtec.com/imprint>.

Sign up <https://www.mvtec.com/newsletter> for our MVTec Newsletter!

Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695

MVTec Software GmbH Logo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191028/be3ec9d7/attachment-0001.html>


More information about the CMake mailing list