Using ninja with imported libraries not working (Windows)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Using ninja with imported libraries not working (Windows)

Brendan Heinonen
I've been struggling to use ninja-generator with imported libraries in CMake on Windows.  The issue started when I moved some third-party code in the project to an external project using find_package.  I have since reduced the issue to a minimally reproducible example:

add_library(foo STATIC IMPORTED)
set_property(TARGET foo PROPERTY IMPORTED_LOCATION E:/path/to/foo.lib)
target_link_libraries(bar foo)

This produces a Ninja error:

ninja : error : 'E:/path/to/foo.lib', needed by 'bar', missing and no known rule to make it

I should note that the path to the lib exists, and in fact, this config works on other generators, such as NMake and Unix Makefiles.

The issue is "fixed" upon manually editing and removing this from the bar link target:


What's the deal?  Am I missing something?  Any help would be appreciated.

Brendan Heinonen


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: