Brad King wrote:
> On 11/29/2012 12:29 PM, Stephen Kelly wrote:
>> Really I think the most practical solution is to generate 'if (NOT
>> TARGET)'
>
> Defining the targets is not the only thing that a targets file does.
> It also sets all the properties. How will you guard those? They
> do not always appear next to the targets. We need a single file-wide
> guard.
Currently GrantleeTargets.cmake looks like this:
# Create imported target grantlee_core
ADD_LIBRARY(grantlee_core SHARED IMPORTED)
SET_TARGET_PROPERTIES(grantlee_core PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "$<$<TARGET_DEFINED:Qt4::QtCore>:
$<TARGET_PROPERTY:Qt4::QtCore,INTERFACE_COMPILE_DEFINITIONS>>"
INTERFACE_INCLUDE_DIRECTORIES "$<$<TARGET_DEFINED:Qt4::QtCore>:
$<TARGET_PROPERTY:Qt4::QtCore,INTERFACE_INCLUDE_DIRECTORIES>>"
)
# Create imported target grantlee_gui
ADD_LIBRARY(grantlee_gui SHARED IMPORTED)
# Load information for each installed configuration.
GET_FILENAME_COMPONENT(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
FILE(GLOB CONFIG_FILES "${_DIR}/GrantleeTargets-*.cmake")
FOREACH(f ${CONFIG_FILES})
INCLUDE(${f})
ENDFOREACH(f)
1) As everything in the same Targets.cmake file was exported together, the
IMPORTED targets for them will be defined all-or-none, so we only need a
guard which checks for the first target.
2) The result of "${_DIR}/GrantleeTargets-*.cmake" can change over time if
new configurations are installed to the same prefix, but I'm sure it's safe
to assume that they won't change *in a single cmake run*. Therefore, once
we've done that once, we don't have to do it again.
1) and 2) imply for me that we can wrap the entire snippet I pasted above in
if (NOT TARGET grantlee_core). Am I missing anything?
Thanks,
Steve.
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers