Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error building cmake project under vscode: Invalid platform #222

Closed
jeffaco opened this issue Aug 9, 2017 · 14 comments
Closed

Error building cmake project under vscode: Invalid platform #222

jeffaco opened this issue Aug 9, 2017 · 14 comments
Labels
bug a bug in the product Feature: configure help wanted we currently are not planning work on this and would like help from the open source community more info needed More info is needed from the community for us to properly triage and investigate.
Milestone

Comments

@jeffaco
Copy link

jeffaco commented Aug 9, 2017

I'm having a problem that I don't understand. In VS Code, I used to be able to click "CMake: No Project: Debug: Configuring", select "Debug", and then a cmake file would be built. I could then click the "build" button and build away.

This stopped working when I returned from vacation. There was an update of VS Code itself (I'm running version 1.14.2 of VS Code) and of the CMake Tools extension (running version 0.10.2), and when I now try to build the CMake file, I get:

[cmake-server] loading initial cache file c:\mesos\mesos\build\CMakeTools\InitializeCache.cmake

-- CMake Error at CMakeLists.txt:25 (project):
  Failed to run MSBuild command:

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise/MSBuild/15.0/Bin/MSBuild.exe

  to get the value of VCTargetsPath:

    Microsoft (R) Build Engine version 15.1.1012.6693
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Build started 8/9/2017 2:56:37 PM.
    Project "c:\mesos\mesos\build\CMakeFiles\3.9.0\VCTargetsPath.vcxproj" on node 1 (default targets).
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.InvalidPlatform.Targets(22,7): error MSB8007: The Platform for project 'VCTargetsPath.vcxproj' is invalid.  Platform=' Win64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Platform that doesn't exist for this project. [c:\mesos\mesos\build\CMakeFiles\3.9.0\VCTargetsPath.vcxproj]
    Done Building Project "c:\mesos\mesos\build\CMakeFiles\3.9.0\VCTargetsPath.vcxproj" (default targets) -- FAILED.
    
    Build FAILED.
    
    "c:\mesos\mesos\build\CMakeFiles\3.9.0\VCTargetsPath.vcxproj" (default target) (1) ->
    (InvalidPlatformError target) -> 
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.InvalidPlatform.Targets(22,7): error MSB8007: The Platform for project 'VCTargetsPath.vcxproj' is invalid.  Platform=' Win64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Platform that doesn't exist for this project. [c:\mesos\mesos\build\CMakeFiles\3.9.0\VCTargetsPath.vcxproj]
    
        0 Warning(s)
        1 Error(s)
    
    Time Elapsed 00:00:00.60
    

  Exit code: 1



-- Configuring incomplete, errors occurred!
See also "c:/mesos/mesos/build/CMakeFiles/CMakeOutput.log".
[vscode] Configure failed: [cmake-server] Configuration failed.

If I run the cmake command manually, it works. The command I use to run cmake manually is:

mkdir build; cd build
cmake .. -G "Visual Studio 15 2017 Win64" -T "host=x64" -DHAS_AUTHENTICATION=OFF -DENABLE_LIBEVENT=ON

Any idea why I'm getting this error? Any help would be appreciated, thanks!

@ytimenkov
Copy link
Contributor

There is a typo in regex which parses generator name to extract platform

To work around I suggest changing generator to something like (i.e. move Win64 from generator name to separate setting):

"cmake.generator": "Visual Studio 15 2017",
"cmake.platform": "x64",
"cmake.toolset": "host=x64"

@jeffaco
Copy link
Author

jeffaco commented Aug 10, 2017

This resolved my problem, thanks so much for the help! Closing issue ...

@jeffaco jeffaco closed this as completed Aug 10, 2017
@jeffaco
Copy link
Author

jeffaco commented Aug 10, 2017

Um, I'm still having some issues with the updates to the cmake tools.

If I build manually with the following commands, then the build is successful:

mkdir build; cd build
cmake .. -G "Visual Studio 15 2017 Win64" -T "host=x64" -DHAS_AUTHENTICATION=OFF -DENABLE_LIBEVENT=ON
cmake --build . --target "mesos-tests"

However, the build fails with compiler errors (perhaps dealing with precompiled headers, I'm unsure) if I select the "Debug" configuration, the "mesos-tests" project, and then click build.

This used to work (although I wasn't keeping up to date for a while on the cmake tools), but it's not with the latest plugin.

Any idea what might be going on? What do the plugin do that's different than from how I'm building?

Thanks, in advance, for any advice.

@jeffaco jeffaco reopened this Aug 10, 2017
@vector-of-bool
Copy link
Contributor

Is it failing with the same error that you mentioned above?

@vector-of-bool vector-of-bool added the bug a bug in the product label Aug 11, 2017
@jeffaco
Copy link
Author

jeffaco commented Aug 11, 2017

Sorry for not being clear. No, the error is different now. The cmake configuration is now read and loaded (which was not happening before you suggested configuration changes) when I select the "Debug" built type. But now the built itself (clicking the "Build" button) is failing with errors like:

         whitelist_watcher.cpp
     8>C:\mesos\mesos\src\version\version.cpp(77): error C2039: 'Response': is not a member of 'mesos::http' [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]
         C:\mesos\mesos\include\mesos\authentication\http\combined_authenticator.hpp(33): note: see declaration of 'mesos::http'
     8>C:\mesos\mesos\src\version\version.cpp(77): error C2065: 'Response': undeclared identifier [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]
     8>C:\mesos\mesos\src\version\version.cpp(77): error C2923: 'process::Future': 'Response' is not a valid template type argument for parameter 'T' [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]
     8>C:\mesos\mesos\src\version\version.cpp(77): error C2039: 'Request': is not a member of 'mesos::http' [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]
         C:\mesos\mesos\include\mesos\authentication\http\combined_authenticator.hpp(33): note: see declaration of 'mesos::http'
     8>C:\mesos\mesos\src\version\version.cpp(78): error C2511: 'process::Future mesos::internal::VersionProcess::version(const mesos::Request &)': overloaded member function not found in 'mesos::internal::VersionProcess' [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]
         C:\mesos\mesos\src\version\version.hpp(57): note: see declaration of 'mesos::internal::VersionProcess'
     8>C:\mesos\mesos\src\version\version.cpp(78): error C2079: 'mesos::internal::VersionProcess::version' uses undefined class 'process::Future' [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]
     8>C:\mesos\mesos\src\version\version.cpp(79): error C2039: 'url': is not a member of 'mesos::Request' [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]
         c:\mesos\mesos\build\src\master/registry.pb.h(307): note: see declaration of 'mesos::Request'
     8>C:\mesos\mesos\src\version\version.cpp(79): error C2228: left of '.query' must have class/struct/union [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]
     8>C:\mesos\mesos\src\version\version.cpp(79): error C2228: left of '.get' must have class/struct/union [C:\mesos\mesos\build\src\mesos-1.4.0.vcxproj]

These errors, at very quick glance, are the type of errors that we get from precompiled header problems. BUT: What's interesting here is that if I build via the command line (using the commands I specified above invoking cmake directly), then the build works fine.

So, this begs the question: What is the CMake Tools plugin doing differently to build than the "direct" cmake build command:

cmake --build . --target "mesos-tests"

If I build via the above command, all is well. But if I click the "Build" button in VS Code, the build fails.

Thanks for your help, and sorry I wasn't clear before.

@jeffaco
Copy link
Author

jeffaco commented Aug 16, 2017

Any update on this problem, by chance? Thanks in advance ...

@vector-of-bool
Copy link
Contributor

@jeffaco, I'm so sorry to leave this up in the air. Been busy with "real life" things, which is a common theme in this repo... Hmm...

I'm looking to do some refactors that should help with issues like this. I'll try and catch this one on the way through. I'm thinking it may be related to environment variables. What version of CMake are you using?

@jeffaco
Copy link
Author

jeffaco commented Sep 22, 2017

@vector-of-bool I'm currently running cmake version 3.9.0. If version of cmake is a contributing factor, I can run any version >= 3.7.0. My project has a dependency on cmake version 3.7.0 or later.

Thanks for your help!

@no-realm no-realm added this to the 0.11.0 milestone Mar 1, 2018
@vector-of-bool
Copy link
Contributor

@jeffaco, I know it has been a while, but the recent 0.11.0-beta5 release changes some things about loading the Visual Studio toolsets. Would you be willing to take a look and report back?

@vector-of-bool vector-of-bool modified the milestones: 0.11.0, Backlog Apr 12, 2018
@vector-of-bool vector-of-bool added the more info needed More info is needed from the community for us to properly triage and investigate. label Apr 12, 2018
@Mischa-Alff
Copy link

I have the same issue when trying to build with x86 toolset Visual Studio 15 2017

@vector-of-bool vector-of-bool added the help wanted we currently are not planning work on this and would like help from the open source community label Aug 14, 2018
@vector-of-bool
Copy link
Contributor

Sorry, I'm really at a loss on this one.

Anyone reading this: Help!

@jclay
Copy link

jclay commented Aug 29, 2018

For anyone else that's running into this issue, I was able to resolve this by configuring the generator in the workspace instead of the kit:

// cmake-tools.json
{
    "name": "VS2017 CUDA Support",
    "visualStudio": "34360ca7",
    "visualStudioArchitecture": "x86_amd64",
    "preferredGenerator": {
      "name": "Visual Studio 15 2017",
      "platform": "x64",
      "toolset": "version=14.13"
    },
    "toolchainFile": "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
  },

the preferredGenerator setting becomes:

// settings.json (workspace settings)
{
    "cmake.generator": "Visual Studio 15 2017",
    "cmake.toolset": "version=14.13",
    "cmake.platform": "x64"
}

Based on a really brief dive into the source code, it looks like the workspace settings take precedence here, so if you're specifying the generator in your workspace, all other generator settings from the kit will be overridden. I'm seeing that in driver.ts#L478

For anyone trying to debug this issue, I'd recommend enabling the cmake server protocol debug messages. You can do this by editing src/cms-client.js in the plugin directory and changing the ENABLE_CMSERVER_PROTO_DEBUG to be true.

@vector-of-bool what do you think about adding a setting to enable or disable this? I find having this enabled gives me a much better diagnosis of where things are going wrong in the CMake server setup process. Happy to start on a PR if you're in agreement here.

@vector-of-bool
Copy link
Contributor

@jclay sorry for the delay here. I've had a lot on my plate recently.

Any setting to enable more troubleshooting is a welcome addition! I'd gladly accept a PR.

@github-actions
Copy link

This issue has been closed automatically because it needs more information and has not had recent activity.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: configure help wanted we currently are not planning work on this and would like help from the open source community more info needed More info is needed from the community for us to properly triage and investigate.
Projects
None yet
Development

No branches or pull requests

7 participants