diff options
author | Kévin THIERRY <kevin.thierry@open.eurogiciel.org> | 2014-12-23 09:30:24 +0100 |
---|---|---|
committer | Kévin THIERRY <kevin.thierry@open.eurogiciel.org> | 2014-12-23 09:30:24 +0100 |
commit | 317dbdb79761ef65e45c7358cfc7571c6afa54ad (patch) | |
tree | d6e8d59029aea04ca4a0579fb1c19c3e493af78f /Tests/IncludeDirectories | |
parent | 297c63fa65327491a2b50e521b661c5835a19fe4 (diff) | |
download | cmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.tar.gz cmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.tar.bz2 cmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.zip |
Imported Upstream version 2.8.12.2upstream/2.8.12.2sandbox/kevinthierry/upstream
Diffstat (limited to 'Tests/IncludeDirectories')
13 files changed, 143 insertions, 0 deletions
diff --git a/Tests/IncludeDirectories/CMP0021/CMakeLists.txt b/Tests/IncludeDirectories/CMP0021/CMakeLists.txt new file mode 100644 index 000000000..0b9aee899 --- /dev/null +++ b/Tests/IncludeDirectories/CMP0021/CMakeLists.txt @@ -0,0 +1,14 @@ + +cmake_policy(SET CMP0021 OLD) +add_executable(cmp0021exe main.cpp) + +if(NOT CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/includes") + execute_process(COMMAND ${CMAKE_COMMAND} -E + copy_directory + "${CMAKE_CURRENT_SOURCE_DIR}/includes" + "${CMAKE_CURRENT_BINARY_DIR}/includes" + ) +endif() +set_property(TARGET cmp0021exe PROPERTY + INCLUDE_DIRECTORIES includes/cmp0021) diff --git a/Tests/IncludeDirectories/CMP0021/includes/cmp0021/cmp0021.h b/Tests/IncludeDirectories/CMP0021/includes/cmp0021/cmp0021.h new file mode 100644 index 000000000..3d49b31d5 --- /dev/null +++ b/Tests/IncludeDirectories/CMP0021/includes/cmp0021/cmp0021.h @@ -0,0 +1,2 @@ + +#define CMP0021_DEFINE diff --git a/Tests/IncludeDirectories/CMP0021/main.cpp b/Tests/IncludeDirectories/CMP0021/main.cpp new file mode 100644 index 000000000..f886c4629 --- /dev/null +++ b/Tests/IncludeDirectories/CMP0021/main.cpp @@ -0,0 +1,11 @@ + +#include "cmp0021.h" + +#ifndef CMP0021_DEFINE +#error Expected CMP0021_DEFINE +#endif + +int main(int, char **) +{ + return 0; +} diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 3e3ecc90d..35ad8dc90 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -1,6 +1,23 @@ cmake_minimum_required (VERSION 2.6) project(IncludeDirectories) +if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) + OR CMAKE_C_COMPILER_ID STREQUAL Clang) + AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) + if(run_sys_includes_test) + # The Bullseye wrapper appears to break the -isystem effect. + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out) + if("x${out}" MATCHES "Bullseye") + set(run_sys_includes_test 0) + endif() + endif() + if (run_sys_includes_test) + add_subdirectory(SystemIncludeDirectories) + endif() +endif() + file(WRITE ${CMAKE_BINARY_DIR}/Flags/Flags.h "//Flags.h ") @@ -69,3 +86,7 @@ get_target_property(incs empty_entry_test INCLUDE_DIRECTORIES) if (NOT incs STREQUAL ";/one/two") message(SEND_ERROR "Empty include_directories entry was not ignored.") endif() + +if(NOT CMAKE_GENERATOR STREQUAL Xcode AND NOT CMAKE_GENERATOR STREQUAL Ninja) + add_subdirectory(CMP0021) +endif() diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt new file mode 100644 index 000000000..aec6ff981 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -0,0 +1,19 @@ + +cmake_minimum_required(VERSION 2.8) + +project(SystemIncludeDirectories) + +add_library(systemlib systemlib.cpp) +target_include_directories(systemlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/systemlib") + +add_library(upstream upstream.cpp) +target_link_libraries(upstream LINK_PUBLIC systemlib) +target_compile_options(upstream PRIVATE -Werror=unused-variable) + +target_include_directories(upstream SYSTEM PUBLIC + $<TARGET_PROPERTY:systemlib,INTERFACE_INCLUDE_DIRECTORIES> +) + +add_library(consumer consumer.cpp) +target_link_libraries(consumer upstream) +target_compile_options(consumer PRIVATE -Werror=unused-variable) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp new file mode 100644 index 000000000..197dae86d --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp @@ -0,0 +1,7 @@ + +#include "upstream.h" + +int consumer() +{ + return upstream(); +} diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp new file mode 100644 index 000000000..f111bfa55 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp @@ -0,0 +1,4 @@ + +#include "systemlib.h" + +int systemlib() { return 0; } diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h new file mode 100644 index 000000000..c84de6a28 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h @@ -0,0 +1,19 @@ + +#ifndef SYSTEMLIB_H +#define SYSTEMLIB_H + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int systemlib(); + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int unusedFunc() +{ + int unused; + return systemlib(); +} + +#endif diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp new file mode 100644 index 000000000..f716b99e6 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp @@ -0,0 +1,4 @@ + +#include "upstream.h" + +int upstream() { return systemlib(); } diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h new file mode 100644 index 000000000..3628568cf --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h @@ -0,0 +1,12 @@ + +#ifndef UPSTREAM_H +#define UPSTREAM_H + +#include "systemlib.h" + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int upstream(); + +#endif diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 4a5aa30bb..8e2bd0a0d 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -147,3 +147,24 @@ target_link_libraries(lib5 libbad libgood) target_include_directories(lib5 BEFORE PRIVATE $<TARGET_PROPERTY:libgood,INTERFACE_INCLUDE_DIRECTORIES> ) + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/prefix_foo/prefix_bar/prefix_bat") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/prefix_foo/prefix_bar/prefix_bat/prefix_foo_bar_bat.h" "// prefix_foo_bar_bat.h\n") + +target_include_directories(TargetIncludeDirectories PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/prefix_$<JOIN:foo;bar;bat,/prefix_>") + +# Test that the language generator expressions work +set_property(TARGET TargetIncludeDirectories + APPEND PROPERTY INCLUDE_DIRECTORIES + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/bad>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/good>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" +) + +add_executable(TargetIncludeDirectories_C main.c) +set_property(TARGET TargetIncludeDirectories_C + APPEND PROPERTY INCLUDE_DIRECTORIES + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/bad>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/good>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" +) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.c b/Tests/IncludeDirectories/TargetIncludeDirectories/main.c new file mode 100644 index 000000000..a597daad0 --- /dev/null +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.c @@ -0,0 +1,7 @@ + +#include "common.h" + +int main(void) +{ + return 0; +} diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp index 90909d334..aed0bde46 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp @@ -10,6 +10,8 @@ #include "arguments.h" #include "list.h" #include "target.h" +#include "prefix_foo_bar_bat.h" +#include "common.h" int main(int, char**) { |