find_package MODULE notification for incompatible versions
Our team was excited to learn about and apply transitive usage requirements
in 2017 using the various target_* cmake commands. We also have moved onto
installing, locally on development machines, many of our common use libraries.
One problem we've run into is involving situations where a find_package for a given
library let's say myLibrary-1.3.1 is installed next to an older version of
the same library say myLibrary-1.1.0. Both are in one of our CMAKE_PREFIX_PATHs.
They were also both installed with the AnyNewerVersion
option using the CMake
provided write_basic_package_version_file
. One client application's top level
CMakeLists.txt calls find_package(myLibrary 1.1 REQUIRED)
and another library
in a subdirectory is added via add_subdirectory and it calls
find_package(myLibrary 1.3 REQUIRED)
in it's CMakeLists.txt file. The behavior
we are seeing is that both calls are "successful" and the myLibrary_DIR
is
updated for each as wells as the myLibrary_VERSION
. But the include directories
and imported library locations are for version 1.1. We looked at the code
generated by the install(EXPORTS...)
command and noted that it is the reason
why subsequent calls have no affect on the include directories and imported
library locations. Specifically the code that prevents already imported targets
from being added again. Are we doing this incorrectly? If not, we would would like
the install(EXPORTS...)
generated code to consider this condition and warn or
fail if a lower version was already found and a higher version is REQUIRED.
Additionally, if this would be a low priority we would be willing to make the
change and submit a change request if you can point us at the place where that
code is located. Thank you.