[cmake-developers] Setting includes, defines and other usage requirements with one command
Brad King
brad.king at kitware.com
Wed Jan 30 10:46:19 EST 2013
On 01/30/2013 03:15 AM, Stephen Kelly wrote:
> Brad King wrote:
>
>>> I've implemented it in the tll-includes-defines branch in my clone. I've
>>> only tested it manually though.
>>
>> Yes, that looks good. Please add tests covering each case:
>
> I've pushed it again to my clone.
>
> Once the fix-target-property-commands topic is in master, we can rebase it
> if needed and get it merged to next.
I just tried your branch with a simple test case:
--------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.10.20130129)
project(FOO C)
set(CMAKE_INSTALL_PREFIX "${FOO_BINARY_DIR}/root")
add_library(foo SHARED foo.c)
target_include_directories(foo PUBLIC
$<BUILD_INTERFACE:${FOO_SOURCE_DIR}>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
)
add_library(bar SHARED bar.c)
#set(m m) # uncommenting breaks this
target_link_libraries(bar LINK_PUBLIC foo ${m})
get_property(iface TARGET bar PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "bar.INTERFACE_INCLUDE_DIRECTORIES = [${iface}]")
export(TARGETS bar foo FILE Targets.cmake)
install(TARGETS bar foo DESTINATION lib EXPORT Foo)
install(EXPORT Foo DESTINATION lib/cmake/foo)
--------------------------------------------------------------------------
It works, but then uncommenting the marked line to tll a non-target
produces:
-- bar.INTERFACE_INCLUDE_DIRECTORIES = [$<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES>;$<$<TARGET_DEFINED:m>:$<TARGET_PROPERTY:m,INTERFACE_INCLUDE_DIRECTORIES>>]
CMake Error at CMakeLists.txt:16 (export):
$<TARGET_PROPERTY:m,prop> requires its first parameter to be a reachable
target.
The TARGET_PROPERTY errors out even though TARGET_DEFINED:m should
be false.
Also, will the non-target expressions added by tll be preprocessed out
during export()/install(EXPORT)?
-Brad
More information about the cmake-developers
mailing list