The remote system does not have CMake 3.8 or greater - c++

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
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.
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?

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)

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)

Related

How can I import a CLion C++ project into Visual Studio?

It seems like this should be easy and I've spent hours trying to find this answer online but haven't had any luck.
I can open the CLion folder path in Visual Studio, but that option doesn't give me the usual options to build and start the project. To do that, I need to open CLion as a Project/Solution, but I can't seem to do this.
My professor requires that my C++ code be executable in Visual Studio, but I prefer CLion. So I've done all my work in CLion and want to test that it runs in Visual Studio. How can I import my CLion project?
Thanks!
The link provided describes Visual Studio's CMake integration, which (similar to CLion) will install a version of CMake that Visual Studio will use. These instructions are pretty thorough and should provide everything needed to get your CMake project working in Visual Studio.
Now, you probably have two versions of CMake installed on your machine, one that came with CLion and one that came with Visual Studio. I would recommend installing the latest version of CMake on your machine separately, and configuring both Visual Studio and CLion to use that version instead. However, this is probably getting outside the scope of your immediate problem.
As you follow the Microsoft's instructions for "CMake projects in Visual Studio", you mentioned receiving the error:
1> [CMake] CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.17/Modules/CMakeDetermineSystem.cmake:173 (file):
1> [CMake] file failed to open for writing (No such file or directory):
This looks like a permissions issue, specifically while running CMake within Visual Studio, so be sure you have read/write access to all the files in your project, and the CMake packages in your Visual Studio installation. Hopefully, this doesn't require you re-install Visual Studio in another location on your machine, or run Visual Studio with elevated privileges, but perhaps that is necessary.
If you decide to install CMake separately, the instructions would be the following:
Install the latest CMake on your machine (somewhere you have adequate permissions), and ensure it is available in your Path environment variable. You can verify this by running cmake -version from the command line to see it is the version you just installed.
Using Windows command prompt, navigate to your CMake project directory (containing the top-level CMakeLists.txt file), and run the following:
mkdir build
cd build
cmake -G "Visual Studio 16 2019" -A x64 ..
You may run -A Win32 with the cmake command instead if your project is a 32-bit build.
Open the .sln Visual Studio Solution file that was generated in the build directory. Once, the Solution is loaded in Visual Studio, you can build the project (CTRL + SHIFT + B).

CMake can't get the value of VCTargetsPath when generating for UWP

I'm trying to use CMake to build a Universal Windows App, but I get the following build error (latest Visual Studio 2019 and Windows 10 SDK are installed):
› cmake -B. -H<my source dir> -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.
CMake Error at CMakeLists.txt:3 (project):
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine version 16.5.1+4616136f8 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 5/16/2020 9:52:00 PM.
Project "C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(777,5): error : The OutputPath property is not set for project 'VCTargetsPath.vcxproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj]
Done Building Project "C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" (default target) (1) ->
(_CheckForInvalidConfigurationAndPlatform target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(777,5): error : The OutputPath property is not set for project 'VCTargetsPath.vcxproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.07
Exit code: 1
-- Configuring incomplete, errors occurred!
What does that mean? I've also tried to specify the exact Windows SDK version for CMAKE_SYSTEM_VERSION, but no luck.
I solved the problem. I did many things, therefore I cannot tell which one exactly solved the problem. But try the following.
From VisualStudio Installer app, click Modify and install C++ Universal Windows Platform support for v142 build tools (ARM64) individual component.

CMake Tools for Visual Studio 2017 stuck parsing

I've the following configuration
Visual Studio 15.9.4
CMake 3.11
When I create a new cmake project from Visual Studio project templates, it starts configuring project as expected and cmake generation completes with no error. The output window of Visual Studio looks like this
1> -- Generating done
1> -- Build files have been written to: C:/Users/Dell/CMakeBuilds/0538efd0-8db3-fb3e-ba15-48b48c82580d/build/x64-Debug (default)
1> Starting CMake target info extraction ...
1> CMake server connection made.
1> Extracted includes paths.
1> Extracted CMake variables. 1> Extracted source files and headers.
1> Extracted global settings.
1> Extracted code model.
1> Extracted CTest info.
1> Collating data ...
1> Target info extraction done.
But the problem occurs when I try to build, no targets appear, cmake target view of solution explorer says it is still parsing CMakeLists.txt. When I tried to compile with command line it finishes with no error and I am able to run the program.
It is a bit hard to see what is going on since you don't show any source code, but I use cmake on the command line to generate solutions files and load them in Visual Studio 2017.
You just need to that once, when you update the CMakeLists.txt files you can save them and compiler them via CTRL + F7 and then reload the solution and project that has updated. This works for small changes.
I also found using cmake directly was very slow since I have a large project. It seems to work well in clion that I use on Linux.

Cannot build LLVM on Windows 10 using Visual Studio 2015

I'm trying to install LLVM on Windows 10 using Visual Studio, using the guide http://llvm.org/docs/GettingStartedVS.html, but I'm getting errors:
Here is my view in CMake GUI, where I've directed it to use the C++ compiler C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe.
I've already created a new directory called llvm for the build, since I cannot build in the source directory.
What am I doing wrong?
The configure process displays the following output:
The C compiler identification is unknown
The CXX compiler identification is unknown
The ASM compiler identification is MSVC
Found assembler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
CMake Error at CMakeLists.txt:48 (project):
No CMAKE_C_COMPILER could be found.
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
CMake Error: Generator: execution of make failed. Make command was: "MSBuild.exe" "cmTC_c88f4.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/CMakeTestCXXCompiler.cmake:44 (message):
The C++ compiler "C:/Program Files (x86)/Microsoft Visual Studio
14.0/VC/bin/cl.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/dev/llvm/CMakeFiles/CMakeTmp
Run Build Command:"MSBuild.exe" "cmTC_c88f4.vcxproj"
"/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
Generator: execution of make failed. Make command was: "MSBuild.exe"
"cmTC_c88f4.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:48 (project)
Configuring incomplete, errors occurred!
See also "C:/dev/llvm/CMakeFiles/CMakeOutput.log".
See also "C:/dev/llvm/CMakeFiles/CMakeError.log".
I am working with your same setup(exception being Windows 32-bit), the LLVM version I have chosen is 4.0.0. I followed the tutorial for setting it up with clang.
I made notes for my entire process.
Instructions for building LLVM 4.0.0 from source:
Create a folder named LLVM in any suitable location.
cd LLVM
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm\tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd .... # going back to where you started
mkdir build
cd build
cmake -G "Visual Studio 14" ..\llvm ##depends on the version of VS you use, I used VS 2015 -> VISUAL STUDIO 14.0
If successful, in the build directory you will find LLVM.sln file which can be opened in Visual Studio, once opened, you can navigate through the solution explorer and right click the ALL_BUILD project -> Build.
Notes:
I'm using Visual Studio 2015 (Update 3)
I'm using Windows 10 32-bit system
Header files dependencies can be fixed by appending paths to the files where it can be found in the Visual Studio 14.0 folder in Program Files.
My environment variables for reference:
**INCLUDE=C:\Program Files\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt;C:\Program Files\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files\Windows Kits\8.1\include\shared;C:\Program Files\Windows Kits\8.1\include\um;C:\Program Files\Windows Kits\8.1\include\winrt;
**LIBPATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft Visual Studio 14.0\VC\LIB;C:\Program Files\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB;C:\Program Files\Windows Kits\8.1\References\CommonConfiguration\Neutral;\Microsoft.VCLibs\14.0\References\CommonConfiguration\neutral;
Set the PATH enviroment variable for llvm tools like clang, llc, lli, etc., if they're not recognized on developer command prompt.
You may also find executables like clang and clang++ missing from the build when downloading from the github. I copied these from the prebuilt binaries which I had downloaded for windows which can be found on the LLVM releases page.
Hope this helps!

CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found

I'm trying make a Visual Studio solution with CMake to compile the latest version of aseprite and CMake keeps giving me the:
No CMAKE_C_COMPILER could be found.
No CMAKE_CXX_COMPILER could be found.
I've already downloaded GCC, and I'm using Visual Studio 2015.
I'm following this tutorial:
https://github.com/aseprite/aseprite/blob/master/INSTALL.md
For Ubuntu, please install the below things:
sudo apt-get update && sudo apt-get install build-essential
Those error messages
CMake Error at ... (project):
No CMAKE_C_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also ".../CMakeFiles/CMakeOutput.log".
See also ".../CMakeFiles/CMakeError.log".
or
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.
Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
...
-- Configuring incomplete, errors occurred!
just mean that CMake was unable to find your C/CXX compiler to compile a simple test program (one of the first things CMake tries while detecting your build environment).
The steps to find your problem are dependent on the build environment you want to generate. The following tutorials are a collection of answers here on Stack Overflow and some of my own experiences with CMake on Microsoft Windows 7/8/10 and Ubuntu 14.04.
Preconditions
You have installed the compiler/IDE and it was able to once compile any other program (directly without CMake)
You e.g. may have the IDE, but may not have installed the compiler or supporting framework itself like described in Problems generating solution for VS 2017 with CMake or How do I tell CMake to use Clang on Windows?
You have the latest CMake version
You have access rights on the drive you want CMake to generate your build environment
You have a clean build directory (because CMake does cache things from the last try) e.g. as sub-directory of your source tree
Windows cmd.exe
> rmdir /s /q VS2015
> mkdir VS2015
> cd VS2015
Bash shell
$ rm -rf MSYS
$ mkdir MSYS
$ cd MSYS
and make sure your command shell points to your newly created binary output directory.
General things you can/should try
Is CMake able find and run with any/your default compiler? Run without giving a generator
> cmake ..
-- Building for: Visual Studio 14 2015
...
Perfect if it correctly determined the generator to use - like here Visual Studio 14 2015
What was it that actually failed?
In the previous build output directory look at CMakeFiles\CMakeError.log for any error message that make sense to you or try to open/compile the test project generated at CMakeFiles\[Version]\CompilerIdC|CompilerIdCXX directly from the command line (as found in the error log).
CMake can't find Visual Studio
Try to select the correct generator version:
> cmake --help
> cmake -G "Visual Studio 14 2015" ..
If that doesn't help, try to set the Visual Studio environment variables first (the path could vary):
> "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
> cmake ..
or use the Developer Command Prompt for VS2015 short-cut in your Windows Start Menu under All Programs/Visual Studio 2015/Visual Studio Tools (thanks at #Antwane for the hint).
Background: CMake does support all Visual Studio releases and flavors (Express, Community, Professional, Premium, Test, Team, Enterprise, Ultimate, etc.). To determine the location of the compiler it uses a combination of searching the registry (e.g. at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[Version];InstallDir), system environment variables and - if none of the others did come up with something - plainly try to call the compiler.
CMake can't find GCC (MinGW/MSys)
You start the MSys bash shell with msys.bat and just try to directly call gcc
$ gcc
gcc.exe: fatal error: no input files
compilation terminated.
Here it did find gcc and is complaining that I didn't gave it any parameters to work with.
So the following should work:
$ cmake -G "MSYS Makefiles" ..
-- The CXX compiler identification is GNU 4.8.1
...
$ make
If GCC was not found call export PATH=... to add your compilers path (see How to set PATH environment variable in CMake script?) and try again.
If it's still not working, try to set the CXX compiler path directly by exporting it (path may vary)
$ export CC=/c/MinGW/bin/gcc.exe
$ export CXX=/c/MinGW/bin/g++.exe
$ cmake -G "MinGW Makefiles" ..
-- The CXX compiler identification is GNU 4.8.1
...
$ mingw32-make
For more details see How to specify new GCC path for CMake
Note: When using the "MinGW Makefiles" generator you have to use the mingw32-make program distributed with MinGW
Still not working? That's weird. Please make sure that the compiler is there and it has executable rights (see also preconditions chapter above).
Otherwise the last resort of CMake is to not try any compiler search itself and set CMake's internal variables directly by
$ cmake -DCMAKE_C_COMPILER=/c/MinGW/bin/gcc.exe -DCMAKE_CXX_COMPILER=/c/MinGW/bin/g++.exe ..
For more details see Cmake doesn't honour -D CMAKE_CXX_COMPILER=g++ and Cmake error setting compiler
Alternatively those variables can also be set via cmake-gui.exe on Windows. See Cmake cannot find compiler
Background: Much the same as with Visual Studio. CMake supports all sorts of GCC flavors. It searches the environment variables (CC, CXX, etc.) or simply tries to call the compiler. In addition it will detect any prefixes (when cross-compiling) and tries to add it to all binutils of the GNU compiler toolchain (ar, ranlib, strip, ld, nm, objdump, and objcopy).
This happened to me after I installed Visual Studio 15 2017.
The C++ compiler for Visual Studio 14 2015 was not the problem. It seemed to be a problem with the Windows 10 SDK.
Adding the Windows 10 SDKs to Visual Studio 14 2015 solved the problem for me.
See attached screenshot.
This works for me in Ubuntu 17.10 (Artful Aardvark):
apt-get update
apt-get install build-essential
I also experienced this error when working with CMake:
No CMAKE_C_COMPILER could be found.
No CMAKE_CXX_COMPILER could be found.
The 'warning' box in the MSDN library article Visual C++ in Visual Studio 2015 gave me the help that I needed.
Visual Studio 2015 doesn't come with C++ installed by default. So, creating a new C++ project will prompt you to download the necessary C++ components.
I ran into this issue while building libgit2-0.23.4. For me the problem was that C++ compiler & related packages were not installed with VS2015, therefore "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" file was missing and Cmake wasn't able to find the compiler.
I tried manually creating a C++ project in the Visual Studio 2015 GUI (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe)
and while creating the project, I got a prompt to download the C++ & related packages.
After downloading required packages, I could see vcvarsall.bat & Cmake was able to find the compiler & executed successfully with following log:
C:\Users\aksmahaj\Documents\MyLab\fritzing\libgit2\build64>cmake ..
-- Building for: Visual Studio 14 2015
-- The C compiler identification is MSVC 19.0.24210.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual
Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual
Studio 14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- zlib was not found; using bundled 3rd-party sources.
-- LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of
the default search path.
-- Looking for futimens
-- Looking for futimens - not found
-- Looking for qsort_r
-- Looking for qsort_r - not found
-- Looking for qsort_s
-- Looking for qsort_s - found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Found PythonInterp: C:/csvn/Python25/python.exe (found version "2.7.1")
-- Configuring done
-- Generating done
-- Build files have been written to:
C:/Users/aksmahaj/Documents/MyLab/fritzing/libgit2/build64
I had the same errors with CMake. In my case, I have used the wrong Visual Studio version in the initial CMake dialog where we have to select the Visual Studio compiler.
Then I changed it to "Visual Studio 11 2012" and things worked. (I have Visual Studio Ultimate 2012 version on my PC). In general, try to input an older version of Visual Studio version in the initial CMake configuration dialog.
For me, this problem went away on Windows when I moved my project to a shallower parent directory, i.e. to:
C:\Users\spenc\Desktop\MyProjectDirectory
instead of
C:\Users\spenc\Desktop\...\MyProjectDirectory.
I think the source of the problem was that MSBuild has a file path length restriction to 260 characters. This causes the basic compiler test CMake performs to build a project called CompilerIdCXX.vcxproj to fail with the error:
C1083: Cannot open source file: 'CMakeCXXCompilerId.cpp'
because the length of the file's path e.g.
C:\Users\spenc\Desktop\...\MyProjectDirectory\build\CMakeFiles\...\CMakeCXXCompilerId.cpp
exceeds the MAX_PATH restriction.
CMake then concludes there is no CXX compiler.
Make sure you have selected the correct version of Visual Studio. This is trickier than it seems because Visual Studio 2015 is actually Visual Studio 14, and similarly Visual Studio 2012 is Visual Studio 11. I had incorrectly selected Visual Studio 15 which is actually Visual Studio 2017, when I had 2015 installed.
After trying out all of the solutions with no luck, I just provided those missing parameter by cmake -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ ...
Make sure you have installed Windows SDK when you were installing Visual Studio. To add windows SDK you can go to Visual Studio Installer and hit "Modify" and then tick the checkbox of Windows SDK and install it.
None of the solutions here solves my problem - only when I install Windows Update for universal C runtime.
Now CMake is working and no more link hangs from Visual Studio.
Update for Universal C Runtime in Windows
You can also make sure you are the sudo user and you have READ/WRITE access on the directory you are working. I had a similar problem on OS X, and I got it fixed just by entering in sudo mode.
Just in case it helps any one like me in future:
I have had this issue for 24 hours now, on 3 different 64-bit machines(Win7 , Windows 8.1 VM and WIn 8.1 laptop) - whilst trying to build WebKit with VS 2017.
The simple issue here is that the VC++ compiler (i.e cl.exe and it's dependent DLLs) is not visible to CMake. Simple. By making the VC++ folders containing those binaries visible to CMake and your working command prompt(if you're running Cmake from a command prompt), voila! (In addition to key points raised by others , above)
Anyway, after all kinds of fixes - as posted on these many forums- I discovered that it was SIMPLY a matter of ensuring that the PATH variable's contents are not cluttered with multiple Visual Studio BIN paths etc; and instead, points to :
a) the location of your compiler (i.e. cl.exe for your preferred version of Visual Studio ), which in my case(targeting 64-bit platform, and developing on a 64-bit host) is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64
b) and in addition, the folder containing a dependent DLL called (which cl.exe is dependent on):
api-ms-win-crt-runtime-l1-1-0.dll - which on my machine is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Remote Debugger\x64
These two directories being added to a simplified and CUSTOM System Path variable(working under a Admin priviledged commmand prompt), eliminated my "No CMAKE_C_COMPILER could be found" and "No CMAKE_CXX_COMPILER could be found." errors.
Hope it helps someone.
I get exactly the reported error if ccache is enabled, when using CMake's Xcode generator. Disabling ccache fixed the problem for me. Below I present a fix/check that works for MacOS, but should work similarly on other platforms.
Apparently, it is possible to use CMake's Xcode generator (and others) also in combination with ccache, as is described here. But I never tried it out myself.
# 1) To check if ccache is enabled:
echo $CC
echo $CXX
# This prints something like the following:
# ccache clang -Qunused-arguments -fcolor-diagnostics.
# CC or CXX are typically set in the `.bashrc` or `.zshrc` file.
# 2) To disable ccache, use the following:
CC=clang
CXX=clang++
# 3) Then regenerate the cmake project
cmake -G Xcode <path/to/CMakeLists.txt>
I know this question is about visual studio 2015. I faced this issue with visual studio 2017. When searched on google I landed to this page. After looking at first 2,3 answers I realized this is the problem with vc++ installation. Installing the workload "Desktop development with c++" resolved the issue.
I updated Visual Studio 2015 update 2 to Visual Studio 2015 update 3, and it solved my problem.
I had the same issue with cmake-gui (No CMAKE_CXX_COMPILER could be found.), while running CMake from the command line worked fine. After manually adding the entries
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
to the PATH environment variable it worked for me.
For me it worked to use the Developer Command Prompt that comes with Visual Studio and then just cd to your/jcef/dir and run cmake -G "Visual Studio 14 Win64" ..
I had the same problem.
I was trying to install dlib on my machine and it gave me this error.
The tutorial mentioned in the question leads to downloading visual studio 2017. I solved this by uninstalling VS 2017 and installing VS 2015
One can install VS 2015 via this stackoverflow thread :
How to download Visual Studio Community Edition 2015 (not 2017)
Look in the Cmakelists.txt if you find ARM you need to install C++ for ARM
It's these packages:
C++ Universal Windows Platform for ARM64 "Not Required"
Visual C++ Compilers and libraries for ARM "Not Required"
Visual C++ Compilers and libraries for ARM64 "Very Likely Required"
Required for finding Threads on ARM
enable_language(C)
enable_language(CXX)
Then the problems
No CMAKE_C_COMPILER could be found.
No CMAKE_CXX_COMPILER could be found.
Might disappear unless you specify c compiler like clang, and maybe installing clang will work in other favour.
You can with optional remove in cmakelists.txt both with # before enable_language if you are not compiling for ARM.
On M1 Mac, add the following config to fix it for me
-DCMAKE_C_COMPILER="${OTHER_CXX_FLAG}" -DCMAKE_C_COMPILER="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -DCMAKE_CXX_COMPILER="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
The config result is:
cmake ../build -DCMAKE_C_COMPILER="${OTHER_CXX_FLAG}" -DCMAKE_C_COMPILER="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -DCMAKE_CXX_COMPILER="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_TARGET_SYSTEM=mac -GXcode