I am in the process of migrating an existing project to CMake. In it, I have several libraries and executables;
When I add one of the library targets (let’s say library lib) to the main executable (let’s call it exe), and “generate”, I currently get a strange error message I cannot find the exact reason for:
Configuring done (1.1s)
CMake Error in librarypath/CMakeLists.txt:
Cannot find source file:
C:/Source/library_autogen/S5YYZ2ZCNV_/qrc_library.cpp
Generating done (8.9s)
So, the executable linking to the library lib causes an error in the library, even when the library itself compiled fine before!
I added the main executable last (since it requires basically all other libraries in the project); all libraries build fine; I can create the executable target , but as soon as I add the target_link_library(exe PRIVATE lib) call, the CMake generation fails with above error.
I ask myself where the “wrong” search directory comes from (note the missing configuration after S5YYZ2ZCNV_ - in the `S5YYZ2ZCNV_Debug directory, the qrc_library.cpp file actually exists, created from a previous Debug build. And how/why can linking via target_link_library call even trigger a failed search for a source in a dependent library?
In lib, there’s Resources/library.qrc , AUTORCC is enabled, and as I said, the lib compiles fine, and it can also be linked to another executable in another folder.
I tried adding –log-level=DEBUG and –debug-output to the cmake command line but this didn’t give me any additional info on where this error is coming from.
I’m sure it’s just some stupid error on my end but I can’t figure out how to further debug this…