diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-11-25 00:15:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-01-08 19:14:27 (GMT) |
commit | 9ce1b9ef2946ead0605e766c7dcf1302fe122f3a (patch) | |
tree | dc757e71d66b28948a587c16e2a8b965ccffde01 /Tests/CMakeCommands/target_link_libraries/subdir | |
parent | c2cde7f1047b2f11e7d4a466000a20d8c42394be (diff) | |
download | CMake-9ce1b9ef2946ead0605e766c7dcf1302fe122f3a.zip CMake-9ce1b9ef2946ead0605e766c7dcf1302fe122f3a.tar.gz CMake-9ce1b9ef2946ead0605e766c7dcf1302fe122f3a.tar.bz2 |
Add CMAKE_BUILD_INTERFACE_INCLUDES build-variable.
This makes
set(CMAKE_BUILD_INTERFACE_INCLUDES ON)
add the equivalent of
set_property(TARGET tgt APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}>
)
to every target.
If the headers are in CMAKE_CURRENT_SOURCE_DIR, and the generated headers
are in CMAKE_CURRENT_BINARY_DIR, this is a convenient way to build a target
bar, which depends on foo, just by using target_link_libraries() and adding
the INTERFACE_INCLUDE_DIRECTORIES to the INCLUDE_DIRECTORIES of the target
being linked. There will be more-convenient porcelain API to consume the
property in the future.
Diffstat (limited to 'Tests/CMakeCommands/target_link_libraries/subdir')
3 files changed, 24 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/target_link_libraries/subdir/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/subdir/CMakeLists.txt new file mode 100644 index 0000000..61a1a59 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/subdir/CMakeLists.txt @@ -0,0 +1,5 @@ + +set(CMAKE_BUILD_INTERFACE_INCLUDES ON) + +add_library(subdirlib SHARED subdirlib.cpp) +generate_export_header(subdirlib) diff --git a/Tests/CMakeCommands/target_link_libraries/subdir/subdirlib.cpp b/Tests/CMakeCommands/target_link_libraries/subdir/subdirlib.cpp new file mode 100644 index 0000000..cd2f1a2 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/subdir/subdirlib.cpp @@ -0,0 +1,7 @@ + +#include "subdirlib.h" + +int SubDirLibObject::foo() const +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/subdir/subdirlib.h b/Tests/CMakeCommands/target_link_libraries/subdir/subdirlib.h new file mode 100644 index 0000000..e386f87 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/subdir/subdirlib.h @@ -0,0 +1,12 @@ + +#ifndef SUBDIRLIB_H +#define SUBDIRLIB_H + +#include "subdirlib_export.h" + +struct SUBDIRLIB_EXPORT SubDirLibObject +{ + int foo() const; +}; + +#endif |