The 3.7.2 version of CMake bundled with Visual Studio 2017 (latest update) cannot on its own find the Visual Studio 2017 build tools.
This is reproducing for me using Visual Studio 2017 with individual components selected.
Using CMake 3.8.1 (current CMake release), the tools can be found no problem.
This becomes problematic when using the Visual Studio CMake tools because the ExternalProject_Add
macro
(used to include third-party CMake driven projects) re-invokes CMake, at which point it fails to find the compilers.
It seems that Visual Studio originally invokes CMake "specially" shomehow as it finds the tools for the top-level project,
but does not retain this environment when ${CMAKE_COMMAND}
is invoked from within the build.
PS C:\Users\andrew\src\mesos\build> cmake --version
cmake version 3.7.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
PS C:\Users\andrew\src\mesos\build> cmake .. -G "Visual Studio 15 2017 Win64" -T "host=x64" -DENABLE_LIBEVENT=1 -DHAS_AUTHENTICATION=0
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:25 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:25 (project):
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also "C:/Users/andrew/src/mesos/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/andrew/src/mesos/build/CMakeFiles/CMakeError.log".
PS C:\Users\andrew\src\mesos\build> cmake --version
cmake version 3.8.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
PS C:\Users\andrew\src\mesos\build> cmake .. -G "Visual Studio 15 2017 Win64" -T "host=x64" -DENABLE_LIBEVENT=1 -DHAS_AUTHENTICATION=0
-- The C compiler identification is MSVC 19.10.25019.0
-- The CXX compiler identification is MSVC 19.10.25019.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.10.25017/bin/HostX64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.10.25017/bin/HostX64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.10.25017/bin/HostX64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.10.25017/bin/HostX64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- cotire 1.7.9 loaded.
-- ************************************************************
-- ********* Beginning Mesos CMake configuration step *********
-- ************************************************************
-- INSTALLATION PREFIX: C:/Program Files/Mesos
-- MACHINE SPECS:
-- Hostname:
-- OS: WINDOWS(10.0.15063)
-- Arch: AMD64
-- BitMode:
-- BuildID:
-- ************************************************************
CMake Warning at cmake/CompilationConfigure.cmake:114 (message):
On Windows, the required versions of:
* ZooKeeper
* protobuf
* glog
* libevent
* curl
* libapr
* zlib
do not come rebundled in the Mesos repository. They will be downloaded
from the Internet, even though the `REBUNDLED` flag was set.
Call Stack (most recent call first):
cmake/MesosConfigure.cmake:51 (include)
CMakeLists.txt:61 (include)
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- GnuWin32 patch.exe exists at: C:/Program Files (x86)/GnuWin32/bin/patch.exe
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- CXX target mesos-1.4.0 cotired.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/andrew/src/mesos/build
PS C:\Users\andrew\src\mesos\build>
The corresponding CMakeSettings.json
can be found here.
1> Command line: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\install" -DENABLE_LIBEVENT="1" -DHAS_AUTHENTICATION="0" -T host=x64 -DCMAKE_CONFIGURATION_TYPES="Debug" "C:\Users\andschwa\src\mesos"
1> Working directory: C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\x64-Debug
1> -- cotire 1.7.9 loaded.
1> -- ************************************************************
1> -- ********* Beginning Mesos CMake configuration step *********
1> -- ************************************************************
1> -- INSTALLATION PREFIX: C:/Users/andschwa/AppData/Local/CMakeBuild/bb480876-3d6e-ba35-8f97-ffc120e14f87/build/install
1> -- MACHINE SPECS:
1> -- Hostname:
1> -- OS: WINDOWS(10.0.15063)
1> -- Arch: AMD64
1> -- BitMode:
1> -- BuildID:
1> -- ************************************************************
1> CMake Warning at cmake/CompilationConfigure.cmake:114 (message):
1> On Windows, the required versions of:
1>
1> * ZooKeeper
1> * protobuf
1> * glog
1> * libevent
1> * curl
1> * libapr
1> * zlib
1>
1> do not come rebundled in the Mesos repository. They will be downloaded
1> from the Internet, even though the `REBUNDLED` flag was set.
1> Call Stack (most recent call first):
1> cmake/MesosConfigure.cmake:51 (include)
1> CMakeLists.txt:61 (include)
1>
1>
1> -- GnuWin32 patch.exe exists at: C:/Program Files (x86)/GnuWin32/bin/patch.exe
1> -- CXX target mesos-1.4.0 cotired.
1> -- Configuring done
1> -- Generating done
1> -- Build files have been written to: C:/Users/andschwa/AppData/Local/CMakeBuild/bb480876-3d6e-ba35-8f97-ffc120e14f87/build/x64-Debug
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> Collating data ...
1> Target info extraction done.
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 5/11/2017 12:15:08 PM.
Project "C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\x64-Debug\3rdparty\http_parser-2.6.2.vcxproj" on node 1 (default targets).
Project "C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\x64-Debug\3rdparty\http_parser-2.6.2.vcxproj" (1) is building "C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\x64-Debug\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
InitializeBuildStatus:
Creating "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
All outputs are up-to-date.
FinalizeBuildStatus:
Deleting file "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
Touching "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Done Building Project "C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\x64-Debug\ZERO_CHECK.vcxproj" (default targets).
InitializeBuildStatus:
Touching "x64\Debug\http_parser-2.6.2\http_par.AFD9A5B9.tlog\unsuccessfulbuild".
CustomBuild:
Building Custom Rule C:/Users/andschwa/src/mesos/3rdparty/CMakeLists.txt
CMake does not need to re-run because C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\x64-Debug\3rdparty\CMakeFiles\generate.stamp is up-to-date.
Creating directories for 'http_parser-2.6.2'
Performing download step (verify and extract) for 'http_parser-2.6.2'
CMake Warning at http_parser-2.6.2-stamp/verify-http_parser-2.6.2.cmake:15 (message):
File will not be verified since no URL_HASH specified
-- extracting...
src='C:/Users/andschwa/src/mesos/3rdparty/http-parser-2.6.2.tar.gz'
dst='C:/Users/andschwa/AppData/Local/CMakeBuild/bb480876-3d6e-ba35-8f97-ffc120e14f87/build/x64-Debug/3rdparty/http_parser-2.6.2/src/http_parser-2.6.2'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
Performing update step for 'http_parser-2.6.2'
Performing patch step for 'http_parser-2.6.2'
(Stripping trailing CRs from patch.)
patching file http_parser.h
Performing configure step for 'http_parser-2.6.2'
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:24 (project):
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also "C:/Users/andschwa/AppData/Local/CMakeBuild/bb480876-3d6e-ba35-8f97-ffc120e14f87/build/x64-Debug/3rdparty/http_parser-2.6.2/src/http_parser-2.6.2-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/andschwa/AppData/Local/CMakeBuild/bb480876-3d6e-ba35-8f97-ffc120e14f87/build/x64-Debug/3rdparty/http_parser-2.6.2/src/http_parser-2.6.2-build/CMakeFiles/CMakeError.log".
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
Done Building Project "C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\x64-Debug\3rdparty\http_parser-2.6.2.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\andschwa\AppData\Local\CMakeBuild\bb480876-3d6e-ba35-8f97-ffc120e14f87\build\x64-Debug\3rdparty\http_parser-2.6.2.vcxproj" (default target) (1) ->
(CustomBuild target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.49
Build failed.
Hm, that doesn't seem to be doing it. FWIW the only non-bundled version of CMake I have on this machine is 3.8.1;
ExternaProject_Add
is spawning the bundled 3.7.2 (not 3.7.2 proper, as it's not installed).So, having started VS with it's bundle CMake at the front of the path, my projects still fail like:
That said, I have worked around this instead by setting the
ExternalProject_Add
propertyCMAKE_COMMAND
toC:\Program Files\CMake\bin\cmake.exe
(CMake 3.8.1):When set to 3.8.1:
it works. When set to the bundled CMake 3.7.2 (path tested above):
it fails by not finding the compilers.
Just to double check that bundled path:
I have to force it to use the 3.8.1 version, the bundled one isn't working.
P.S. I am excited to hear VS will bundle 3.8.1 soon!