[cmake-developers] Should sucessive calls to find_package for one package succeed?
Brad King
brad.king at kitware.com
Mon Nov 7 10:27:24 EST 2011
On 11/7/2011 10:18 AM, Stephen Kelly wrote:
> Ok, thanks. Seems like an important thing to document. Is there any page
> showing how to use config files and targets files?
http://www.cmake.org/Wiki/CMake/Tutorials#CMake_Packages
This section:
http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Packaging_and_Exporting
could be updated with that suggestion.
>>> if (NOT TARGET grantlee_templates)
>>> ADD_LIBRARY(grantlee_templates SHARED IMPORTED)
>>> endif()
>>
>> This would hide cases of accidentally conflicting target names.
>
> I don't understand.
If an application defines a target named "foo" as part of its own build
and then uses find_package to load a dependency that also defines "foo"
then a target-wise blocker like the above will silently skip the imported
target. Then the imported dependency won't link correctly because it
will use the application's foo instead of the package's foo. We need to
allow the add_library command to complain about an existing target.
-Brad
More information about the cmake-developers
mailing list