[cmake-developers] Should sucessive calls to find_package for one package succeed?

Brad King brad.king at kitware.com
Mon Nov 7 08:33:20 EST 2011


On 11/6/2011 7:00 PM, Stephen Kelly wrote:
> include(${CMAKE_CURRENT_LIST_DIR}/GrantleeTargets.cmake)

It is up to the author of the config file to block this correctly
against multiple inclusion, e.g.

  if(NOT Grantlee_TARGETS_INCLUDED)
    set(Grantlee_TARGETS_INCLUDED 1)
    include(${CMAKE_CURRENT_LIST_DIR}/GrantleeTargets.cmake)
  endif()

> if (NOT TARGET grantlee_templates)
>    ADD_LIBRARY(grantlee_templates SHARED IMPORTED)
> endif()

This would hide cases of accidentally conflicting target names.

-Brad



More information about the cmake-developers mailing list