Hi,
Due to some peculiar setup, I need to add a bit of custom logic to the behavior of CMake provided Find.
The expected behavior for my projects would be: when calling find_package(<Module> ...
it should call my version of Find which, in turn, according to some conditions, may call the CMake provided version of Find.
Besides, how can I make a find_dependency
call in a configuration file to use the same logic?
I found this proposal (not tested yet) and I was wondering if there could be another (“better”) solution.
NB If I understand correctly the documentation, find_dependency
may call return()
thus getting back to the “caller” before resetting CMAKE_MODULE_PATH
.
Regards,
A.
Help still needed.
A special case is: A depends privately on B that depends privately on C that comes in 2 flavors: A cl compliant version and a gcc one (on the same machine).
In B CMakeLists
, according to the compiler, I check different user environment variables to set C_DIR
accordingly, find_package
then find the desired C version. In A, I’ve got a linker error, because the find_package(B)
loads B configuration file that does not embedded any special logic, it only does find_dependency(C)
which may find a different, non-compliant, version of C.
My configuration file is automatically generated from a template that only lists the dependencies.
So my first idea has been the motivation for my question: I’m considering that, on some machine, find_package
for a given library, must follow some logic. Yet it might not be a good approach as, how will it know, for instance, the compiler in use or other information required to chose the right version?
Another idea would be to be able to embed some special code in the template-generated configuration file. If it should be considered the right way to go, I may open a new question to this goal.
Regards,
A.