0

I'm trying to target a simple CMake-based project to Linux (x86) from VS2017.

CMakeLists.txt

project (hello-cmake)
add_executable(hello-cmake hello.cpp)

hello.cpp

#include <iostream>

int main(int argc, char* argv[])
{
    std::cout << "Hello from Linux CMake" << std::endl;
}

My setup:

  • Visual Studio 15.8.2 running on Win7
  • Ubuntu 16.04
  • CMake 3.12.1
  • g++ 5.4.0, gcc 5.4.0

I've carefully read the instructions on MSDN's website, but cannot get it to work.

Using the default CMakeSettings.json generated by VS, the rsync command proceeded to wipe my '~' directory!

Below the command as it appears in VS:

rsync -t --delete --delete-excluded -v -r --exclude=.vs --exclude=.git --exclude=.vs --exclude=.git  /D/JP/svn/mirtec/test_cmake_vs2017/ rsync://alex@localhost:60584/temp

I understand what the --delete --delete-excluded does. But I do not understand why is it targeting my home directory?

How am I meant to specify the location on the target machine where the files will be copied (I thought it was remoteCMakeListsRoot, but my experience shows it is not).

Am I meant to create a dedicated user for VS/CMake debugging?

I edited the CMakeSettings.json to remove the "--delete --delete-excluded" options. As result rsync stops trying to wipe ~, but now VS says it cannot find CMake! I am completely stuck. I have installed CMake and it is available in /usr/local/bin. I have tried with and without the name of the program to cmakeExecutable in the json file to no avail.

This is the output in VS:

1> Copying files to remote machine...
1> rsync -t -v -r --exclude=.vs --exclude=.git --exclude=.vs --exclude=.git  /D/JP/svn/mirtec/test_cmake_vs2017/ rsync://alex@localhost:56138/temp
1> sending incremental file list
1> ./
1> CMakeSettings.json
1> 
1> sent 828 bytes  received 42 bytes  580.00 bytes/sec
1> total size is 1349  speedup is 1.55
1> Finished copying files.
1> /usr/local/bin/cmake does not exist

Is there anyone out there using the VS2017 / CMake integration to target Linux successfully? Have you had similar issues? Am I missing something?

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
JPh
  • 536
  • 3
  • 20
  • From this error `1> /usr/local/bin/cmake does not exist` it simply looks like it can't find CMake. Have you installed cmake on your Linux OS and if so, is it inside of your `PATH`? (i.e. to test, simply call cmake from the command line). It just looks like it's having a problem locating CMake, not the actual CMake script itself. – Chris Sep 06 '18 at 19:07
  • Yes, I have installed CMake on my Linux box and it is on the PATH, although I suspect the point of supplying its location in the json file is that it does not need to be on the PATH. – JPh Sep 07 '18 at 08:05

1 Answers1

1

I met the same error as yours but finally solved it.

  • 1 Check weather the cmake is installed in you linux or not.

  • 2 Find the CMakeSetting.json file in your vs2017 project,it is automatic generated by vs2017 when building, the problem is in this file.

    Check the "cmakeExecutable": "/usr/bin/cmake" option,and make sure the path is the same as your remote linux.(use which cmake to check the path ).As your mentioned,the "cmakeExecutable": /usr/local/bin/cmake should be "cmakeExecutable": /usr/bin/cmake.

Community
  • 1
  • 1
jagger2048
  • 11
  • 2