Skip to content

Commit 03e0452

Browse files
authored
[CMAKE] Don't set iwyu and clang-tidy properties on nlohmann_json with cmake <3.19 (open-telemetry#3568)
1 parent 4c41390 commit 03e0452

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
runs-on: ubuntu-24.04
5959
env:
6060
CXX_STANDARD: '17'
61+
CMAKE_VERSION: '3.14.0'
6162
BUILD_TYPE: 'Debug'
6263
steps:
6364
- name: Harden the runner (Audit all outbound calls)
@@ -70,6 +71,7 @@ jobs:
7071
- name: setup
7172
run: |
7273
sudo -E ./ci/setup_ci_environment.sh
74+
sudo -E ./ci/setup_cmake.sh
7375
- name: install dependencies
7476
run: |
7577
sudo -E apt-get update

cmake/nlohmann-json.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ if(NOT nlohmann_json_FOUND)
3535
# Set the nlohmann_json_VERSION variable from the git tag.
3636
string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" nlohmann_json_VERSION "${nlohmann-json_GIT_TAG}")
3737

38-
#Disable iwyu and clang-tidy
39-
if(TARGET nlohmann_json)
38+
# Disable iwyu and clang-tidy only if the CMake version is greater or equal to 3.19.
39+
# CMake 3.19+ is needed to set the iwyu and clang-tidy properties on the INTERFACE target
40+
if(TARGET nlohmann_json AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.19")
4041
set_target_properties(nlohmann_json PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ""
4142
CXX_CLANG_TIDY "")
4243
endif()

0 commit comments

Comments
 (0)