Hi,
Let me start off by saying that I have some 3ed party code that I do not want to modify if possible.
We are trying to move to use the Ninja generators from visual studio generators. I have ran into a problem with this 3ed party code. It is on windows and creates an import lib from an exe not a dll. Since this is non standard, trying to consume this implib has been problematic with ninja. When we used the visual studio generators we just added the path to the implib in the target_link_libraries and added a dependency on the exe that produces this implib to ensure that it was built before anyone tries to consume it implib.
Unfortunately, with ninja it is not that simple. when we try to just add the path to the lib ninja complains that it does not know how to build the file before the dependency is built. If I prebuild the dependency all is fine. This is telling me that ninja can link to it but does not know how to generate it and it is not processing the explicit dependency I added but instead trying to resolve it from its graph.
I though this could be solved with an imported library (or maybe interface I am not completely sure which one). I tried to add an imported interface but ninja is trying to link the to lib of the import not the underlying module specified in INTERFACE_LINK_LIBRARIES.
Lets say I have a executable target called proj which in addition to the exe also creates the proj.lib. This is the link lib I am trying to import. When I try to import this directly ninja complains it does not know how to build it if it is not already built. When I try to build an imported interface, lest call this proj_imported it gives me a linker error since it tries to open proj_imported.lib and it is not found.
LINK : fatal error LNK1104: cannot open file ‘proj_imported.lib’
add_library(proj_imported INTERFACE IMPORTED)
set_property(TARGET proj_imported PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_BINARY_DIR}/external/proj.lib")
Then in the project that is trying to consume proj.lib
add_dependencies(my_test proj)
target_link_libraries(my_test PRIVATE proj_imported)
When I link my_test it complains that it cannot open file proj_imported.lib as I mentioned above.
How do I get ninja to understand that this this is a valid import lib that I am trying to link against?
Thanks for any help with this as I really do not want to modify the code to create a dll that exports this as it is a non trivial amount of work to decouple this into a standalone dll.