Gyp:生成 x64 Visual Studio 解决方案

Gyp: generate x64 Visual Studio solution

从下面的 gyp 文件生成 .sln 和 .vcxproj 后,msbuild 失败并显示

"C:\proj\test\test.sln" (default target) (1) -> (ValidateSolutionConfiguration target) ->
C:\proj\test\test.sln.metaproj : error MSB4126: The specified soluti on configuration "Default|X64" is invalid. Please specify a valid solution conf iguration using the Configuration and Platform properties (e.g. MSBuild.exe Sol ution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properti es blank to use the default solution configuration. [C:\proj\test\test.sln]

如何让 gyp 生成默认|x64 解决方案?

  {
    'targets': [
      {
        'target_name': 'test',
        'type': 'executable',
        'sources': [
          'test.cpp',          
        ],
      },
    ],
  }

可能您需要声明目标配置并将其用作默认值 target_default,类似于:

{
    'target_defaults': {
        'default_configuration': 'Release_x64',
        'configurations':
        {
            'Debug': {
                # configuration specific settings
            },
            'Release': {
                # configuration specific settings
            },
            'Debug_x64': {
                'inherit_from': ['Debug'],
                'msvs_configuration_platform': 'x64',
            },
            'Release_x64': {
                'inherit_from': ['Release'],
                'msvs_configuration_platform': 'x64',
            },
        },
    },

    'targets': [
        {
            'target_name': 'test',
            'type': 'executable',
            'sources': [
                'test.cpp',          
            ],
        },
    ],
}