[cmake-developers] Should sucessive calls to find_package for one package succeed?
Stephen Kelly
steveire at gmail.com
Sun Nov 6 19:00:15 EST 2011
Hi,
Should successive calls to find_package succeed in general?
Eg
find_package(Grantlee COMPONENTS Templates)
find_package(Grantlee COMPONENTS TextDocument)
?
Currently if the target package uses Config files and
install(TARGETS ... EXPORT)
the convention is to use
include(${CMAKE_CURRENT_LIST_DIR}/GrantleeTargets.cmake)
in the config file. The problem is that that Targets file uses an unguarded
ADD_LIBRARY(grantlee_templates SHARED IMPORTED)
which cmake errors on:
add_library cannot create imported target "grantlee_templates" because
another target with the same name already exists.
The fix appears to be to wrap the call to add_library:
if (NOT TARGET grantlee_templates)
ADD_LIBRARY(grantlee_templates SHARED IMPORTED)
endif()
I can fix this if it is a bug.
Thanks,
Steve.
More information about the cmake-developers
mailing list