Search code examples
64-bitgyp

Gyp: generate x64 Visual Studio solution


After generating a .sln and .vcxproj from the gyp file below msbuild fails with

"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]

how do I make gyp generate a Default|x64 solution?

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

Solution

  • Probably you need to have declared target configuration and use it as a default value of target_default, similar to this:

    {
        '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',          
                ],
            },
        ],
    }