Skip to content

Commit b3762cd

Browse files
authored
actually perform system tinyxml2 build on macos / fixed system tinyxml2 include (#4445)
* lib/CMakeLists.txt: removed unnecessary external include * look up tinyxml2 include dir when using system one and specify it * lib/CMakeLists.txt: do not treat bundled headers as system ones * CI-unixish.yml: actually perform system tinyxml2 build on macos
1 parent 2d37a77 commit b3762cd

7 files changed

Lines changed: 31 additions & 8 deletions

File tree

.github/workflows/CI-unixish.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222

2323
- name: ccache
2424
uses: hendrikmuhs/ccache-action@v1.2
25-
if: contains(matrix.os, 'ubuntu')
2625
with:
2726
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
2827

@@ -36,16 +35,21 @@ jobs:
3635
- name: Install missing software on macos
3736
if: contains(matrix.os, 'macos')
3837
run: |
39-
brew install coreutils qt@5
38+
brew install coreutils qt@5 tinyxml2
4039
4140
- name: CMake build on ubuntu (with GUI / system tinyxml2)
4241
if: contains(matrix.os, 'ubuntu')
4342
run: |
4443
cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
4544
cmake --build cmake.output.tinyxml2 -- -j$(nproc)
4645
46+
- name: CMake build on macos (with GUI / system tinyxml2)
47+
if: contains(matrix.os, 'macos')
48+
run: |
49+
cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt5_DIR=$(brew --prefix qt@5)/lib/cmake/Qt5
50+
cmake --build cmake.output.tinyxml2 -- -j$(nproc)
51+
4752
- name: Run CMake test (system tinyxml2)
48-
if: contains(matrix.os, 'ubuntu')
4953
run: |
5054
cmake --build cmake.output.tinyxml2 --target check -- -j$(nproc)
5155

cli/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ add_library(cli_objs OBJECT ${hdrs} ${srcs})
77
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
88
if(USE_BUNDLED_TINYXML2)
99
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
10+
else()
11+
target_include_directories(cli_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
1012
endif()
1113
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
1214

@@ -24,6 +26,8 @@ add_executable(cppcheck ${cppcheck_SOURCES})
2426
target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
2527
if(USE_BUNDLED_TINYXML2)
2628
target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
29+
else()
30+
target_include_directories(cppcheck SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
2731
endif()
2832
target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
2933
if (HAVE_RULES)

cmake/findDependencies.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ if (NOT USE_BUNDLED_TINYXML2)
5858
find_package(tinyxml2 QUIET)
5959
if (TARGET tinyxml2::tinyxml2)
6060
set(tinyxml2_LIBRARIES "tinyxml2::tinyxml2")
61+
set(tinyxml2_INCLUDE_DIRS $<TARGET_PROPERTY:tinyxml2::tinyxml2,INTERFACE_INCLUDE_DIRECTORIES>)
6162
else()
6263
find_library(tinyxml2_LIBRARIES tinyxml2)
63-
if (NOT tinyxml2_LIBRARIES)
64+
find_path(tinyxml2_INCLUDE_DIRS tinyxml2.h)
65+
if (NOT tinyxml2_LIBRARIES AND NOT tinyxml2_INCLUDE_DIRS)
6466
message(FATAL_ERROR "tinyxml2 has not been found")
6567
else()
6668
set(tinyxml2_FOUND 1)

cmake/printInfo.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ message( STATUS )
6767
message( STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}" )
6868
if (NOT USE_BUNDLED_TINYXML2)
6969
message(STATUS "tinyxml2_LIBRARIES = ${tinyxml2_LIBRARIES}")
70+
message(STATUS "tinyxml2_INCLUDE_DIRS = ${tinyxml2_INCLUDE_DIRS}")
7071
endif()
7172
message( STATUS )
7273
message( STATUS "USE_BOOST = ${USE_BOOST}" )

gui/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ if (BUILD_GUI)
2929
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
3030
if(USE_BUNDLED_TINYXML2)
3131
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
32+
else()
33+
target_include_directories(cppcheck-gui SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
3234
endif()
3335
if (HAVE_RULES)
3436
target_link_libraries(cppcheck-gui ${PCRE_LIBRARY})

lib/CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ else()
3333
endif()
3434

3535
add_library(lib_objs OBJECT ${srcs_lib} ${hdrs})
36-
target_include_directories(lib_objs SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/externals/)
3736
if(USE_BUNDLED_TINYXML2)
38-
target_include_directories(lib_objs SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
37+
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
38+
else()
39+
target_include_directories(lib_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
3940
endif()
40-
target_include_directories(lib_objs SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
41-
target_include_directories(lib_objs SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
41+
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
42+
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
4243
if (HAVE_RULES)
4344
target_include_directories(lib_objs SYSTEM PRIVATE ${PCRE_INCLUDE})
4445
endif()
@@ -49,3 +50,10 @@ endif()
4950
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
5051
target_precompile_headers(lib_objs PRIVATE precompiled.h)
5152
endif()
53+
54+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
55+
# -Wfloat-equal is generated by picojson.h
56+
set_source_files_properties(cppcheck.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
57+
set_source_files_properties(importproject.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
58+
set_source_files_properties(settings.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
59+
endif()

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if (BUILD_TESTS)
1010
target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/cli/)
1111
if(USE_BUNDLED_TINYXML2)
1212
target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2)
13+
else()
14+
target_include_directories(testrunner SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
1315
endif()
1416
target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
1517
if (HAVE_RULES)

0 commit comments

Comments
 (0)