The remote system does not have CMake 3.8 or greater
Asked Answered
C

3

0
  1. Introduction to the problem

I'm trying to create a MacOS app that prints a "Hello World" in C++ using Visual Studio 2022 (latest release 17.2.0) on Windows and the CMake template so I can connect remotely (using SSH) to the MacOS, I've been following this official Microsoft tutorial

  1. Problem ocurred

The problem is that when I get to the installation step of CMake in MacOS I can't get it to recognize the version of MacOS installed since when I open the project in Windows I get this following message in the console:

1> Copying files to the remote machine.
1> Starting copying files to remote machine.
1> Finished copying files (elapsed time 00h:00m:00s:650ms).
1> CMake generation started for configuration: 'macos-debug'.
1> Found cmake executable at /Users/maria/.vs/cmake/bin/cmake.
1> The remote system does not have CMake 3.8 or greater. An infobar to automatically deploy CMake to the remote system will be displayed if you are building on a supported architecture. See https://aka.ms/linuxcmakeconfig for more info.

It also shows the following message above:

Supported CMake version is not present on 'remote address'. Install  latest CMake binaries from CMake.org? Yes No

And when I press "yes", it says that I actually have cmake installed on the remote MacOS:

1> Copying files to the remote machine.
1> Starting copying files to remote machine.
1> Finished copying files (elapsed time 00h:00m:00s:650ms).
1> CMake generation started for configuration: 'macos-debug'.
1> Found cmake executable at /Users/maria/.vs/cmake/bin/cmake.
1> The remote system does not have CMake 3.8 or greater. An infobar to automatically deploy CMake to the remote system will be displayed if you are building on a supported architecture. See https://aka.ms/linuxcmakeconfig for more info.
CMake binary deployment to the remote machine started. CMake generation will continue automatically after deployment finishes.

CMake binary deployment to the remote machine failed: Installation directory '/Users/maria/.vs/cmake' already exists.
  1. Solution attemps

I have tried to install CMake using brew (latest version available 3.23.1) and making sure that cmake was accessible directly from the MacOS terminal (included in PATH), I also tried doing the procedure following the official guide by installing the image .dmg by copying the "CMake.app" to "/Applications" and adding it to the path using the following command:

export PATH=/Applications/CMake.app/Contents/bin:$PATH

And I even tried to install older versions of CMake (like 3.8.0 or 3.8.1) but the same thing still happened. The expected result is the same as the Microsoft guide shown here:

1> Copying files to the remote machine.
1> Starting copying files to remote machine.
1> Finished copying files (elapsed time 00h:00m:00s:650ms).
1> CMake generation started for configuration: 'macos-debug'.
1> Found cmake executable at /Applications/CMake.app/Contents/bin/cmake.
1> /Applications/CMake.app/Contents/bin/cmake -G "Ninja"  DCMAKE_BUILD_TYPE_STRING="Debug" -DCMAKE_INSTALL_PREFIX
1> [CMake] -- Configuring done
1> [CMake] -- Generating done
1> [CMake] -- Build files have been written to: /Users/cti/.vs/CMakeProject90/out/build/macos-debug
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted includes paths.
1> CMake generation finished.

Does anyone know why this is happening or what could be the solution to this problem?

Coming answered 17/5, 2022 at 16:21 Comment(3)
Please avoid pictures in your questions. For example, I cannot see them.Carisacarissa
meta.#286051Mise
@Carisacarissa I removed all the imagesShem
G
2

This seems to be a Visual Studio bug. You can keep track of it here.

Workaround

It looks like Visual Studio always looks for CMake under local folder of currently connected via SSH user (i.e. ~/.vs/cmake/bin/cmake), no matter how you installed it. Then, when Visual Studio suggests to install it:

Supported CMake version is not present on ‘192.168.1.180’. Install latest CMake binaries from CMake.org?

If you agree to do that, it actually rolls out it locally in the said folder. The binaries Visual Studio uses are broken and throws an error if you try to use it on the Mac machine locally:

$: ~/.vs/cmake/bin/cmake
zsh: exec format error: /Users/User/.vs/cmake/bin/cmake

That's why Visual Studio keeps struggling to find the working CMake binary. You can get it round by creating a symbolic link to the folder with working CMake binaries in place of the folder Visual Studio looks for them in:

$: rm -rf ~/.vs/cmake/bin
$: ln -s /Applications/CMake.app/Contents/bin ~/.vs/cmake/bin

At this point Visual Studio will be able to locate the CMake, but won't be able to locate the default compilers and generators:

1> /Users/User/.vs/cmake/bin/cmake -G "Ninja"   -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="/Users/User/.vs/CrossPlatform/out/install/macos-debug"  /Users/User/.vs/CrossPlatform/CMakeLists.txt;
1> [CMake] CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
1> [CMake] CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
1> [CMake] CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

The simplest way to fix that is just by running this command on the Mac machine. It will generate the cache Visual Studio can use then, however be advised that whenever this cache is invalidated for whatever reason (e.g. when switching between configurations), you will have to re-generate it again the same way. Another option is to specify all missing parameters explicitly (either via CMakeLists.txt or as command line arguments under cacheVariables property of CMakePresets.json)

Guava answered 18/5, 2022 at 23:28 Comment(0)
C
2

I have finally solved the problem, I had to copy the files located within the CMake application: /Applications/CMake.app/Contents/bin/cmake to the location where Visual Studio was trying to find them, which in my case was: /Users/maria/.vs/cmake/bin/cmake

The version was not a problem since I tried it with the latest CMake version (3.23.1) and it worked. Finally I found a problem related to the lack of indication of the locations of the compilers for C++ and C for CMake and the location of Ninja, I simply specified it inside CMakePresets.json and I had no major problems:

    {
        "name": "macos-debug",
        "displayName": "macOS Debug",
        "generator": "Ninja",
        "binaryDir": "${sourceDir}/out/build/${presetName}",
        "installDir": "${sourceDir}/out/install/${presetName}",
        "cacheVariables": {
          "CMAKE_BUILD_TYPE": "Debug",
          "CMAKE_C_COMPILER": "/usr/bin/gcc",
          "CMAKE_CXX_COMPILER": "/usr/bin/g++",
          "CMAKE_MAKE_PROGRAM": "/usr/local/bin/ninja"
        },
        "condition": {
            "type": "equals",
            "lhs": "${hostSystemName}",
            "rhs": "Darwin"
        },
        "vendor": {
            "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
                "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
            }
        }
    }

I hope someone will find this a helpful solution when developing on MacOS with Visual Studio (on Windows)

Coming answered 18/5, 2022 at 7:58 Comment(1)
Good job. I tried the steps given by Microsoft and it looks like VS just ignores global settings on the MacOS for some reason (it always looks for the local cmake). The cmake binary it deploys seems to be malfunctioning and it makes the whole mechanism broken. I'll submit my observation to Microsoft, they need to fix thatGuava
G
2

This seems to be a Visual Studio bug. You can keep track of it here.

Workaround

It looks like Visual Studio always looks for CMake under local folder of currently connected via SSH user (i.e. ~/.vs/cmake/bin/cmake), no matter how you installed it. Then, when Visual Studio suggests to install it:

Supported CMake version is not present on ‘192.168.1.180’. Install latest CMake binaries from CMake.org?

If you agree to do that, it actually rolls out it locally in the said folder. The binaries Visual Studio uses are broken and throws an error if you try to use it on the Mac machine locally:

$: ~/.vs/cmake/bin/cmake
zsh: exec format error: /Users/User/.vs/cmake/bin/cmake

That's why Visual Studio keeps struggling to find the working CMake binary. You can get it round by creating a symbolic link to the folder with working CMake binaries in place of the folder Visual Studio looks for them in:

$: rm -rf ~/.vs/cmake/bin
$: ln -s /Applications/CMake.app/Contents/bin ~/.vs/cmake/bin

At this point Visual Studio will be able to locate the CMake, but won't be able to locate the default compilers and generators:

1> /Users/User/.vs/cmake/bin/cmake -G "Ninja"   -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="/Users/User/.vs/CrossPlatform/out/install/macos-debug"  /Users/User/.vs/CrossPlatform/CMakeLists.txt;
1> [CMake] CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
1> [CMake] CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
1> [CMake] CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

The simplest way to fix that is just by running this command on the Mac machine. It will generate the cache Visual Studio can use then, however be advised that whenever this cache is invalidated for whatever reason (e.g. when switching between configurations), you will have to re-generate it again the same way. Another option is to specify all missing parameters explicitly (either via CMakeLists.txt or as command line arguments under cacheVariables property of CMakePresets.json)

Guava answered 18/5, 2022 at 23:28 Comment(0)
S
0

I think this is a bug of visual studio. Open the Tool menu in Visual Studio, then open Options-Cross-Platform-Logging and Diagnostics, check Startup Logging and Log into the cross-platform logging space in the output window.

Here is a screenshot

Then regenerate, switch to cross-platform logging, and you will see how visual studio finds cmake. The realpath -m -L cmake and readlink -f -m cmake commands are used. The parameters of this command can work on linux, but they are wrong on macOS. Also, which cmake command is running directly in macOS terminal is also correct, but visual studio gets a wrong value of 1, which I think is a bug of visual studio.

11:06:26.3008967 [Info, Thread 72]  liblinux.RemoteSystemBase: Connecting over SSH to 172.16.166.87:22
11:06:26.8752198 [Info, Thread 85]  liblinux.IO.RemoteFileSystemImpl: Connecting over SFTP to 172.16.166.87:22
11:06:27.3023959 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "realpath -m -L /Users/sobey/.vs/CMakeProject2" finished with exit code 1 after 11.4896ms
11:06:27.3147959 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "readlink -f -m /Users/sobey/.vs/CMakeProject2" finished with exit code 1 after 12.3538ms
11:06:27.3232282 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "echo /Users/sobey/.vs/CMakeProject2" finished with exit code 0 after 8.7827ms
11:06:27.3386039 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "realpath -m -L /Users/sobey/.vs/CMakeProject2" finished with exit code 1 after 11.1806ms
11:06:27.3485238 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "readlink -f -m /Users/sobey/.vs/CMakeProject2" finished with exit code 1 after 10.2662ms
11:06:27.3569562 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "echo /Users/sobey/.vs/CMakeProject2" finished with exit code 0 after 8.3939ms
11:06:27.3594358 [Info, Thread 85]  liblinux.RemoteSystemBase: Disconnecting over SSH from "172.16.166.87:22"
11:06:27.3594358 [Info, Thread 85]  liblinux.IO.RemoteFileSystemImpl: Disconnecting over SFTP from 172.16.166.87:22
11:06:27.3703480 [Info, Thread 56]  liblinux.RemoteSystemBase: Connecting over SSH to 172.16.166.87:22
11:06:27.7060812 [Info, Thread 85]  liblinux.IO.RemoteFileSystemImpl: Connecting over SFTP to 172.16.166.87:22
11:06:28.1425157 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "realpath -m -L /Users/sobey/.vs/CMakeProject2/out/build/macos-debug" finished with exit code 1 after 10.7206ms
11:06:28.1528399 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "readlink -f -m /Users/sobey/.vs/CMakeProject2/out/build/macos-debug" finished with exit code 1 after 10.239ms
11:06:28.1612972 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "echo /Users/sobey/.vs/CMakeProject2/out/build/macos-debug" finished with exit code 0 after 8.1892ms
11:06:28.1712170 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "realpath -m -L /Users/sobey/.vs/CMakeProject2" finished with exit code 1 after 10.1788ms
11:06:28.1821286 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "readlink -f -m /Users/sobey/.vs/CMakeProject2" finished with exit code 1 after 10.5324ms
11:06:28.1900667 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "echo /Users/sobey/.vs/CMakeProject2" finished with exit code 0 after 8.1115ms
11:06:28.1999858 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "realpath -m -L cmake" finished with exit code 1 after 9.6801ms
11:06:28.2099052 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "readlink -f -m cmake" finished with exit code 1 after 9.7734ms
11:06:28.2183364 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "echo cmake" finished with exit code 0 after 8.357ms
11:06:28.2282572 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "which cmake" finished with exit code 1 after 8.9331ms
11:06:28.2381776 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "realpath -m -L $HOME/.vs/cmake/bin/cmake" finished with exit code 1 after 10.0032ms
11:06:28.2485936 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "readlink -f -m $HOME/.vs/cmake/bin/cmake" finished with exit code 1 after 10.105ms
11:06:28.2565294 [Info, Thread 85]  liblinux.Shell.CommonCommandBase: Command "echo $HOME/.vs/cmake/bin/cmake" finished with exit code 0 after 8.1526ms
11:06:28.2590084 [Info, Thread 76]  liblinux.RemoteSystemBase: Disconnecting over SSH from "172.16.166.87:22"
11:06:28.2595046 [Info, Thread 76]  liblinux.IO.RemoteFileSystemImpl: Disconnecting over SFTP from 172.16.166.87:22

Log screenshot

Terminal execution command screenshot

Shawna answered 9/5, 2023 at 3:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.