From 2fd57d3ed1e7c60109660b03f83928607f5f4f34 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 17 Jul 2020 14:26:22 +0200 Subject: [PATCH] :white_check_mark: add test for target_include_directories #1818 --- test/CMakeLists.txt | 1 + .../CMakeLists.txt | 16 ++++++++++++++++ .../project/CMakeLists.txt | 11 +++++++++++ .../project/main.cpp | 8 ++++++++ 4 files changed, 36 insertions(+) create mode 100644 test/cmake_target_include_directories/CMakeLists.txt create mode 100644 test/cmake_target_include_directories/project/CMakeLists.txt create mode 100644 test/cmake_target_include_directories/project/main.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 91ff5a21..76ba31d8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -193,3 +193,4 @@ add_subdirectory(cmake_import) add_subdirectory(cmake_import_minver) add_subdirectory(cmake_add_subdirectory) add_subdirectory(cmake_fetch_content) +add_subdirectory(cmake_target_include_directories) diff --git a/test/cmake_target_include_directories/CMakeLists.txt b/test/cmake_target_include_directories/CMakeLists.txt new file mode 100644 index 00000000..da738ea4 --- /dev/null +++ b/test/cmake_target_include_directories/CMakeLists.txt @@ -0,0 +1,16 @@ +add_test(NAME cmake_target_include_directories_configure + COMMAND ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -Dnlohmann_json_source=${PROJECT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/project +) +add_test(NAME cmake_target_include_directories_build + COMMAND ${CMAKE_COMMAND} --build . +) +set_tests_properties(cmake_target_include_directories_configure PROPERTIES + FIXTURES_SETUP cmake_target_include_directories +) +set_tests_properties(cmake_target_include_directories_build PROPERTIES + FIXTURES_REQUIRED cmake_target_include_directories +) diff --git a/test/cmake_target_include_directories/project/CMakeLists.txt b/test/cmake_target_include_directories/project/CMakeLists.txt new file mode 100644 index 00000000..20e971a0 --- /dev/null +++ b/test/cmake_target_include_directories/project/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) + +project(DummyImport CXX) + +add_executable(with_private_target main.cpp) +target_include_directories(with_private_target PRIVATE ${nlohmann_json_source}/include) +set_target_properties(with_private_target PROPERTIES CXX_STANDARD 11) + +add_executable(with_private_system_target main.cpp) +target_include_directories(with_private_system_target PRIVATE SYSTEM ${nlohmann_json_source}/include) +set_target_properties(with_private_system_target PROPERTIES CXX_STANDARD 11) diff --git a/test/cmake_target_include_directories/project/main.cpp b/test/cmake_target_include_directories/project/main.cpp new file mode 100644 index 00000000..d2d118b8 --- /dev/null +++ b/test/cmake_target_include_directories/project/main.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc, char **argv) +{ + nlohmann::json j; + + return 0; +}