cmake
config_error
ai_generated
true
CMake Error: IMPORTED_LOCATION not set for imported target
ID: cmake/imported-target-missing
85%Fix Rate
83%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3 | active | — | — | — |
Root Cause
Imported target from find_package does not have location property set.
genericWorkarounds
-
88% success Use find_library to locate the actual library file
find_library(FOO_LIB foo PATHS /usr/lib /usr/local/lib)
-
85% success Install the missing package and ensure CMake config files exist
sudo apt install libfoo-dev provides FooConfig.cmake
Dead Ends
Common approaches that don't work:
-
Set IMPORTED_LOCATION to a guessed library path
80% fail
Path may not exist on all systems or architectures.
-
Skip the find_package and hardcode library path
85% fail
Breaks portability across different OS and install locations.