Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 从命令行在CMake项目上设置MSVC运行时_Windows_Cmake_Windows Runtime - Fatal编程技术网

Windows 从命令行在CMake项目上设置MSVC运行时

Windows 从命令行在CMake项目上设置MSVC运行时,windows,cmake,windows-runtime,Windows,Cmake,Windows Runtime,调用CMake时,有没有办法在命令行上设置MSVC运行时?我希望避免必须更改CMakeList.txt 谢谢CMake不支持从命令行设置MSVC运行时库。事实上,CMake最近才获得了通过设置MSVC运行时的支持。但是,您可以使用自定义命令行变量来影响MSVC\u RUNTIME\u库变量在项目中的定义方式。在您的CMake代码中添加以下内容: if(MY_MSVC_RUNTIME STREQUAL "MT") message("Setting MT(d)") set_prope

调用CMake时,有没有办法在命令行上设置MSVC运行时?我希望避免必须更改
CMakeList.txt


谢谢

CMake不支持从命令行设置MSVC运行时库。事实上,CMake最近才获得了通过设置MSVC运行时的支持。但是,您可以使用自定义命令行变量来影响
MSVC\u RUNTIME\u库
变量在项目中的定义方式。在您的CMake代码中添加以下内容:

if(MY_MSVC_RUNTIME STREQUAL "MT")
    message("Setting MT(d)")
    set_property(TARGET MyTarget PROPERTY
        MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
elseif(MY_MSVC_RUNTIME STREQUAL "MD")
    message("Setting MD(d)")
    set_property(TARGET MyTarget PROPERTY
        MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
else()
    message("Setting MT(d) (default)")
    set_property(TARGET MyTarget PROPERTY
        MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
这允许您从命令行在
多线程
多线程之间切换。
调试部分将根据Visual Studio解决方案配置(调试或发布)自动添加或排除

cmake -DMY_MSVC_RUNTIME=MD ..