microsoft / microsoft/vscode-cmake-tools

CMake not able to compile test programs ("No such file or directory")

Open
#1,376 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature: other question
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

CMake beginner here. I've got cygwin64 installed to `c:/cygwin64/`. When I run VS Code and try to create a project using `CMake: Quickstart`, what I get is this `CMakeLists.txt`:

```
cmake_minimum_required(VERSION 3.0.0)
project(CMakeTest VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(CMakeTest main.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
```

As an output I get this:

```
[main] Configuring folder: CMakeTest
[proc] Executing command: C:\cygwin64\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\cygwin64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\cygwin64\bin\g++.exe -Hc:/work/test/CMakeTest -Bc:/work/test/CMakeTest/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is unknown
[cmake] -- The CXX compiler identification is unknown
[cmake] CMake Error at c:/work/test/CMakeTest/CMakeLists.txt:2 (project):
[cmake] The CMAKE_C_COMPILER:
[cmake]
[cmake] C:/cygwin64/bin/gcc.exe
[cmake]
[cmake] is not a full path and was not found in the PATH.
[cmake]
[cmake] Tell CMake where to find the compiler by setting either the environment
[cmake] variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
[cmake] the compiler, or to the compiler name if it is in the PATH.
[cmake]
[cmake]
[cmake] CMake Error at c:/work/test/CMakeTest/CMakeLists.txt:2 (project):
[cmake] The CMAKE_CXX_COMPILER:
[cmake]
[cmake] C:/cygwin64/bin/g++.exe
[cmake]
[cmake] is not a full path and was not found in the PATH.
[cmake]
[cmake] Tell CMake where to find the compiler by setting either the environment
[cmake] variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
[cmake] to the compiler, or to the compiler name if it is in the PATH.
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
```

I read that this can come from CMake finding or assuming a compiler but failing to compile a simple test program. What I found in `CMakeError.log` confirms this:
```
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/cygwin64/bin/gcc.exe
Build flags:
Id flags:

The output was:
No such file or directory
```
and many many more "No such file or directory" messages. Yet, gcc.exe is right where it's supposed to be. What am I not getting here?

### Platform and Versions

- **Operating System**: Windows 10
- **CMake Version**: 3.18.0
- **VSCode Version**: 1.47.2
- **CMake Tools Extension Version**: 1.4.1
- **Compiler/Toolchain**: gcc via cygwin64 3.1.6-1

Also, what's probably actually a bug, I noticed that the plugin seems to create a folder in my project folder, with the path "c\work\test\CMakeTest\build\CMakeFiles", which is then actually the absolute path "C:\work\test\CMakeTest\c\work\test\CMakeTest\build\CMakeFiles" and where my CMakeError.log and CMakeOutput.log are put. It contains the following:

```
...
CMakeFiles
|- 3.14.5
| |_ CompilerC
| | |_ tmp
| | |_ CMakeCCompilerId.c
| |_ CompilerCXX
| | |_ tmp
| | |_ CMakeCXXCompilerId.cpp
|_ CMakeError.log
|_ CMakeOutput.log
```

I suppose this is not as designed, but I'm also not sure if this causes my issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CMake: Quickstart invocation and compare the generated CMakeLists.txt with the CMakeError.log and CMakeOutput.log paths shown in the report. Trace how CMake Tools passes the Cygwin compiler paths and constructs the build directory on Windows. Done means compiler detection works and logs are written under the intended build directory without the malformed nested path.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.