microsoft / microsoft/vscode-cmake-tools

Target properties not evaluated: cannot open file '*-NOTFOUND.obj'

Open
#1,443 5 comments 0 reactions 0 assignees View on GitHub
bug Feature: configure investigation needed
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

Importing an external static library via "add_library" and "set_target_properties" leads to an unexpected linking error:
[build] LINK : fatal error LNK1104: cannot open file '*-NOTFOUND.obj'

### Expected:

1) In CMakeLists.txt define a target for an external static library (not a cmake project) and pass it to target_link_libraries:

```
add_library(Thislib STATIC IMPORTED)
set_target_properties(Thislib PROPERTIES
IMPORTED_LOCATION "${THISLIB_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${THISLIB_INCLUDE_DIR}"
)

target_link_libraries( ${PROJECT_NAME}
Thislib
)
```
where THISLIB_STATIC_LIB and THISLIB_INCLUDE_DIR are ultimately defined in CMakeCache.txt .

2) Use Visual Studio Generator to generate, build and install everything. This works all fine, if done, e.g., within Visual Studio or manually.

### Apparent Behavior:

If doing step 2) from above within Visual Studio Code and with vscode-cmake-tools, the following linking error appears:

`[build] LINK : fatal error LNK1104: cannot open file 'Thislib-NOTFOUND.obj'`

However, looking into the Visual Studio project files one finds that all paths are set correctly. Besides, the static library is of course existing at the right location.

### Platform and Versions

- **Operating System**: Windows 10..0.16299
- **CMake Version**: 3.17.1
- **VSCode Version**: 1.48.0
- **CMake Tools Extension Version**: 1.4.2
- **Compiler/Toolchain**: Visual C++ 2019

Contributor guide

Open the contributing guide

Research direction

Start with the CMakeLists.txt target definition and the related CMakeCache.txt entries, then reproduce the build using the Visual Studio generator through VS Code and CMake Tools. Compare the generated Visual Studio project files with the link command that produces Thislib-NOTFOUND.obj; done means the external imported library links successfully through the extension.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.