cmake + ninja + VS 2017: can't find C compiler or MSVC toolset
On Windows 7. Install cmake 3.15, install cygwin64, install Visual Studio 2017 Express, install python 2.7, install ninja 1.9.0.
I've been using cmake 3.15 with the default Visual Studio 15 2017 generator successfully to build a project, but when I switch to the Ninja generator using cmake -GNinja ...., I get an error from cmake:
-- The C compiler identification is unknown
-- The CXX compiler identification is MSVC 19.16.27032.1
-- Check for working C compiler: C:/cygwin64/bin/cc
-- Check for working C compiler: C:/cygwin64/bin/cc -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/cygwin64/bin/cc"
is not able to compile a simple test program.
It's able to find the correct CXX compiler, which means the PATH must be setup correctly -- why can't cmake find the right C compiler?
One workaround I've attempted adding -DCMAKE_C_COMPILER=cl.exe and -DMSVC_TOOLSET_VERSION=141 as arguments to the cmake command line. This works until my build tries to build an ExternalProject, which then suffers the same problem shown above. It'd be great if cmake could find the right C compiler and the MSVC Toolset.
Is there a better way to do this? Thanks ahead of time.