From a7c4c84d683735339abd221739577dbdbf64d35b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 22 Jul 2020 12:03:37 +0200 Subject: [PATCH 1/5] :white_check_mark: add regression test for #2281 --- .../cmake_target_include_directories/project/Bar.cpp | 3 +++ .../cmake_target_include_directories/project/Bar.hpp | 4 ++++ .../project/CMakeLists.txt | 12 ++++++++++++ .../cmake_target_include_directories/project/Foo.cpp | 3 +++ .../cmake_target_include_directories/project/Foo.hpp | 4 ++++ 5 files changed, 26 insertions(+) create mode 100644 test/cmake_target_include_directories/project/Bar.cpp create mode 100644 test/cmake_target_include_directories/project/Bar.hpp create mode 100644 test/cmake_target_include_directories/project/Foo.cpp create mode 100644 test/cmake_target_include_directories/project/Foo.hpp diff --git a/test/cmake_target_include_directories/project/Bar.cpp b/test/cmake_target_include_directories/project/Bar.cpp new file mode 100644 index 0000000000..ed39e284cf --- /dev/null +++ b/test/cmake_target_include_directories/project/Bar.cpp @@ -0,0 +1,3 @@ +#include "Bar.hpp" + +class Bar; diff --git a/test/cmake_target_include_directories/project/Bar.hpp b/test/cmake_target_include_directories/project/Bar.hpp new file mode 100644 index 0000000000..bdb1d9b5c1 --- /dev/null +++ b/test/cmake_target_include_directories/project/Bar.hpp @@ -0,0 +1,4 @@ +#include +#include "Foo.hpp" + +class Bar : public Foo{}; diff --git a/test/cmake_target_include_directories/project/CMakeLists.txt b/test/cmake_target_include_directories/project/CMakeLists.txt index 20e971a0df..36f3da0cb5 100644 --- a/test/cmake_target_include_directories/project/CMakeLists.txt +++ b/test/cmake_target_include_directories/project/CMakeLists.txt @@ -9,3 +9,15 @@ 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) + +# regression from https://github.com/nlohmann/json/discussions/2281 +add_library(Foo SHARED) +target_sources(Foo PRIVATE Foo.cpp Bar.cpp) +target_include_directories(Foo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_source}/include) +set_target_properties(Foo PROPERTIES CXX_STANDARD 11) + +add_library(Bar SHARED) +target_sources(Bar PRIVATE Bar.cpp) +target_link_libraries(Bar PRIVATE Foo) +target_include_directories(Bar PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_source}/include) +set_target_properties(Bar PROPERTIES CXX_STANDARD 11) diff --git a/test/cmake_target_include_directories/project/Foo.cpp b/test/cmake_target_include_directories/project/Foo.cpp new file mode 100644 index 0000000000..6a2ff91acd --- /dev/null +++ b/test/cmake_target_include_directories/project/Foo.cpp @@ -0,0 +1,3 @@ +#include "Foo.hpp" + +class Foo; diff --git a/test/cmake_target_include_directories/project/Foo.hpp b/test/cmake_target_include_directories/project/Foo.hpp new file mode 100644 index 0000000000..fd6b1ffac0 --- /dev/null +++ b/test/cmake_target_include_directories/project/Foo.hpp @@ -0,0 +1,4 @@ +#pragma once +#include + +class Foo{}; From 4d63252c6cec0eb3fa1db1564cfc213386ed3929 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 22 Jul 2020 12:23:58 +0200 Subject: [PATCH 2/5] :white_check_mark: add regression test for #2281 --- test/cmake_target_include_directories/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cmake_target_include_directories/CMakeLists.txt b/test/cmake_target_include_directories/CMakeLists.txt index da738ea4fe..d0f3335fa1 100644 --- a/test/cmake_target_include_directories/CMakeLists.txt +++ b/test/cmake_target_include_directories/CMakeLists.txt @@ -2,6 +2,7 @@ add_test(NAME cmake_target_include_directories_configure COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_BUILD_TYPE=Debug -Dnlohmann_json_source=${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/project ) From c4356c68e07eba22e5fdd53bd036ee3332b5e87e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 22 Jul 2020 12:38:39 +0200 Subject: [PATCH 3/5] :white_check_mark: add regression test for #2281 --- test/cmake_target_include_directories/CMakeLists.txt | 1 - .../cmake_target_include_directories/project/CMakeLists.txt | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/cmake_target_include_directories/CMakeLists.txt b/test/cmake_target_include_directories/CMakeLists.txt index d0f3335fa1..da738ea4fe 100644 --- a/test/cmake_target_include_directories/CMakeLists.txt +++ b/test/cmake_target_include_directories/CMakeLists.txt @@ -2,7 +2,6 @@ add_test(NAME cmake_target_include_directories_configure COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_BUILD_TYPE=Debug -Dnlohmann_json_source=${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/project ) diff --git a/test/cmake_target_include_directories/project/CMakeLists.txt b/test/cmake_target_include_directories/project/CMakeLists.txt index 36f3da0cb5..a5e0919de5 100644 --- a/test/cmake_target_include_directories/project/CMakeLists.txt +++ b/test/cmake_target_include_directories/project/CMakeLists.txt @@ -11,13 +11,11 @@ target_include_directories(with_private_system_target PRIVATE SYSTEM ${nlohmann_ set_target_properties(with_private_system_target PROPERTIES CXX_STANDARD 11) # regression from https://github.com/nlohmann/json/discussions/2281 -add_library(Foo SHARED) -target_sources(Foo PRIVATE Foo.cpp Bar.cpp) +add_library(Foo SHARED Foo.cpp Bar.cpp) target_include_directories(Foo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_source}/include) set_target_properties(Foo PROPERTIES CXX_STANDARD 11) -add_library(Bar SHARED) -target_sources(Bar PRIVATE Bar.cpp) +add_library(Bar SHARED PRIVATE Bar.cpp) target_link_libraries(Bar PRIVATE Foo) target_include_directories(Bar PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_source}/include) set_target_properties(Bar PROPERTIES CXX_STANDARD 11) From 2301bd1177a9666f1fb5f7bdf407055df88c2bf4 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 22 Jul 2020 13:24:07 +0200 Subject: [PATCH 4/5] :white_check_mark: add regression test for #2281 --- test/cmake_target_include_directories/project/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cmake_target_include_directories/project/CMakeLists.txt b/test/cmake_target_include_directories/project/CMakeLists.txt index a5e0919de5..0f9976952d 100644 --- a/test/cmake_target_include_directories/project/CMakeLists.txt +++ b/test/cmake_target_include_directories/project/CMakeLists.txt @@ -15,7 +15,7 @@ add_library(Foo SHARED Foo.cpp Bar.cpp) target_include_directories(Foo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_source}/include) set_target_properties(Foo PROPERTIES CXX_STANDARD 11) -add_library(Bar SHARED PRIVATE Bar.cpp) +add_library(Bar SHARED Bar.cpp) target_link_libraries(Bar PRIVATE Foo) target_include_directories(Bar PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_source}/include) set_target_properties(Bar PROPERTIES CXX_STANDARD 11) From a6d112ffbf0005cf1a7d61236523bcae89be4ae0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 22 Jul 2020 13:39:40 +0200 Subject: [PATCH 5/5] :white_check_mark: add regression test for #2281 --- test/cmake_target_include_directories/project/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cmake_target_include_directories/project/CMakeLists.txt b/test/cmake_target_include_directories/project/CMakeLists.txt index 0f9976952d..f56786c091 100644 --- a/test/cmake_target_include_directories/project/CMakeLists.txt +++ b/test/cmake_target_include_directories/project/CMakeLists.txt @@ -11,11 +11,11 @@ target_include_directories(with_private_system_target PRIVATE SYSTEM ${nlohmann_ set_target_properties(with_private_system_target PROPERTIES CXX_STANDARD 11) # regression from https://github.com/nlohmann/json/discussions/2281 -add_library(Foo SHARED Foo.cpp Bar.cpp) +add_library(Foo STATIC Foo.cpp Bar.cpp) target_include_directories(Foo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_source}/include) set_target_properties(Foo PROPERTIES CXX_STANDARD 11) -add_library(Bar SHARED Bar.cpp) +add_library(Bar STATIC Bar.cpp) target_link_libraries(Bar PRIVATE Foo) target_include_directories(Bar PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_source}/include) set_target_properties(Bar PROPERTIES CXX_STANDARD 11)