diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-01-01 22:20:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-01-10 14:46:57 (GMT) |
commit | 8a37ebec784cefe4f04cb8897c23a014c3930052 (patch) | |
tree | 6a1fff33c9447c3fbb87f2496baf57fa208f4dec /Tests/CMakeCommands | |
parent | c2cde7f1047b2f11e7d4a466000a20d8c42394be (diff) | |
download | CMake-8a37ebec784cefe4f04cb8897c23a014c3930052.zip CMake-8a37ebec784cefe4f04cb8897c23a014c3930052.tar.gz CMake-8a37ebec784cefe4f04cb8897c23a014c3930052.tar.bz2 |
Add the target_include_directories command.
This is a convenience API to populate the corresponding properties.
Diffstat (limited to 'Tests/CMakeCommands')
3 files changed, 99 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt new file mode 100644 index 0000000..a0f2ee0 --- /dev/null +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 2.8) + +project(target_include_directories) + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/privateinclude") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/privateinclude/privateinclude.h" "#define PRIVATEINCLUDE_DEFINE\n") + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/publicinclude") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/publicinclude/publicinclude.h" "#define PUBLICINCLUDE_DEFINE\n") + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude/interfaceinclude.h" "#define INTERFACEINCLUDE_DEFINE\n") + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude/importedinterfaceinclude.h" "#define IMPORTEDINTERFACEINCLUDE_DEFINE\n") + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/poison") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be included\n") + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cure") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cure/common.h" "#define CURE_DEFINE\n") + +add_executable(target_include_directories + "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" +) +target_include_directories(target_include_directories + PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/privateinclude" + PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/publicinclude" + INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude" +) + +target_include_directories(target_include_directories + PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/poison" +) +target_include_directories(target_include_directories + BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/cure" +) + +add_library(importedlib UNKNOWN IMPORTED) +target_include_directories(importedlib + INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude" +) + +add_executable(consumer + "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" +) + +target_include_directories(consumer + PRIVATE target_include_directories importedlib +) diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp new file mode 100644 index 0000000..6fd61d5 --- /dev/null +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -0,0 +1,27 @@ + +#include "common.h" +#include "publicinclude.h" +#include "interfaceinclude.h" +#include "importedinterfaceinclude.h" + +#ifdef PRIVATEINCLUDE_DEFINE +#error Unexpected PRIVATEINCLUDE_DEFINE +#endif + +#ifndef PUBLICINCLUDE_DEFINE +#error Expected PUBLICINCLUDE_DEFINE +#endif + +#ifndef INTERFACEINCLUDE_DEFINE +#error Expected INTERFACEINCLUDE_DEFINE +#endif + +#ifndef IMPORTEDINTERFACEINCLUDE_DEFINE +#error Expected IMPORTEDINTERFACEINCLUDE_DEFINE +#endif + +#ifndef CURE_DEFINE +#error Expected CURE_DEFINE +#endif + +int main() { return 0; } diff --git a/Tests/CMakeCommands/target_include_directories/main.cpp b/Tests/CMakeCommands/target_include_directories/main.cpp new file mode 100644 index 0000000..8434b97 --- /dev/null +++ b/Tests/CMakeCommands/target_include_directories/main.cpp @@ -0,0 +1,22 @@ + +#include "common.h" +#include "privateinclude.h" +#include "publicinclude.h" + +#ifndef PRIVATEINCLUDE_DEFINE +#error Expected PRIVATEINCLUDE_DEFINE +#endif + +#ifndef PUBLICINCLUDE_DEFINE +#error Expected PUBLICINCLUDE_DEFINE +#endif + +#ifdef INTERFACEINCLUDE_DEFINE +#error Unexpected INTERFACEINCLUDE_DEFINE +#endif + +#ifndef CURE_DEFINE +#error Expected CURE_DEFINE +#endif + +int main() { return 0; } |