'CMake does not generate rules for IMPORTED_IMPLIB

I recently started fixing some broken CMake-based build.

The project relies on a pre-built library (think .lib & .dll file). The dependency is treated as an imported target; i.e. like this:

add_library(the_dependency SHARED IMPORTED GLOBAL)
set_target_properties(
    the_dependency
    PROPERTIES
    IMPORTED_IMPLIB "definitely_correct_path/the_dependency.lib"
)

Building the project using the Visual Studio Generator works fine. However, using Ninja breaks the build leaving me with this error:

ninja: error: 'the_dependency.lib', needed by 'awesome/target', missing and no known rule to make it

Pretty much the same goes for NMake:

NMAKE : fatal error U1073: don't know how to make 'the_dependency.lib'

What I tried:

  • I defined the IMPORTED_LOCATION property additionally.
  • I checked the paths and they're definitely correct.

Also, peaking into the generated build files (i.e. build.ninja), it provides a rule for "generating" the DLL, but none for the LIB file.

Is there something I am missing?



Solution 1:[1]

Have a look at

-DENABLE_EXPORTS=TRUE

https://cmake.org/cmake/help/latest/prop_tgt/ENABLE_EXPORTS.html#prop_tgt:ENABLE_EXPORTS

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Raaam