【问题标题】:Visual Studio 2022 CMake PresetsVisual Studio 2022 CMake 预设
【发布时间】:2023-03-31 15:20:05
【问题描述】:

我在我的项目中使用 CMake,我开始探索 CMakePresets 的可能性

我设法创建了一个默认的 Windows 预设。目前我的 Windows 默认预设将 CMAKE_BUILD_TYPE 设置为调试。 现在我想在左侧下拉列表中选择配置,在右侧下拉列表中选择构建类型(见图)

这有可能吗?

感谢您的帮助

【问题讨论】:

    标签: visual-studio cmake


    【解决方案1】:

    我自己只是理解这一点,但我相信你想要的是像这样设置“buildPresets”:

    {
       "name": "windows-debug",
       "displayName": "Debug",
       "configurePreset": "windows-default",
       "configuration": "Debug"
    },
    {
       "name": "windows-release",
       "displayName": "Release",
       "configurePreset": "windows-default",
       "configuration": "Release"
    }
    

    我认为应该使用“配置”而不是 CMAKE_BUILD_TYPE,因为它与 --config 中的标志相同

    > cmake --build . --config Release
    

    来源:https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#build-preset

    【讨论】:

    • 谢谢你是对的 :)
    猜你喜欢
    • 2022-08-04
    • 2022-06-25
    • 2022-01-10
    • 1970-01-01
    • 2021-12-28
    • 2022-09-25
    • 2021-10-04
    • 2022-01-13
    • 2021-10-27
    相关资源
    最近更新 更多