diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index dfd567310..e4b051783 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -22,7 +22,6 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1.2 - if: contains(matrix.os, 'ubuntu') with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} @@ -36,7 +35,7 @@ jobs: - name: Install missing software on macos if: contains(matrix.os, 'macos') run: | - brew install coreutils qt@5 + brew install coreutils qt@5 tinyxml2 - name: CMake build on ubuntu (with GUI / system tinyxml2) if: contains(matrix.os, 'ubuntu') @@ -44,8 +43,13 @@ jobs: 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 cmake --build cmake.output.tinyxml2 -- -j$(nproc) + - name: CMake build on macos (with GUI / system tinyxml2) + if: contains(matrix.os, 'macos') + run: | + 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 + cmake --build cmake.output.tinyxml2 -- -j$(nproc) + - name: Run CMake test (system tinyxml2) - if: contains(matrix.os, 'ubuntu') run: | cmake --build cmake.output.tinyxml2 --target check -- -j$(nproc) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index aee67e6c2..fa1cbad50 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -7,6 +7,8 @@ add_library(cli_objs OBJECT ${hdrs} ${srcs}) target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/) if(USE_BUNDLED_TINYXML2) target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) +else() + target_include_directories(cli_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) endif() target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/) @@ -24,6 +26,8 @@ add_executable(cppcheck ${cppcheck_SOURCES}) target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/lib/) if(USE_BUNDLED_TINYXML2) target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) +else() + target_include_directories(cppcheck SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) endif() target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/) if (HAVE_RULES) diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index b9d5052e4..460fe4284 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -58,9 +58,11 @@ if (NOT USE_BUNDLED_TINYXML2) find_package(tinyxml2 QUIET) if (TARGET tinyxml2::tinyxml2) set(tinyxml2_LIBRARIES "tinyxml2::tinyxml2") + set(tinyxml2_INCLUDE_DIRS $) else() find_library(tinyxml2_LIBRARIES tinyxml2) - if (NOT tinyxml2_LIBRARIES) + find_path(tinyxml2_INCLUDE_DIRS tinyxml2.h) + if (NOT tinyxml2_LIBRARIES AND NOT tinyxml2_INCLUDE_DIRS) message(FATAL_ERROR "tinyxml2 has not been found") else() set(tinyxml2_FOUND 1) diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index ad5d0c383..0cad74590 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -67,6 +67,7 @@ message( STATUS ) message( STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}" ) if (NOT USE_BUNDLED_TINYXML2) message(STATUS "tinyxml2_LIBRARIES = ${tinyxml2_LIBRARIES}") + message(STATUS "tinyxml2_INCLUDE_DIRS = ${tinyxml2_INCLUDE_DIRS}") endif() message( STATUS ) message( STATUS "USE_BOOST = ${USE_BOOST}" ) diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index d8c885de0..164cd168b 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -29,6 +29,8 @@ if (BUILD_GUI) target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/) if(USE_BUNDLED_TINYXML2) target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) + else() + target_include_directories(cppcheck-gui SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) endif() if (HAVE_RULES) target_link_libraries(cppcheck-gui ${PCRE_LIBRARY}) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 44af140e9..640c526eb 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -33,12 +33,13 @@ else() endif() add_library(lib_objs OBJECT ${srcs_lib} ${hdrs}) -target_include_directories(lib_objs SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/externals/) if(USE_BUNDLED_TINYXML2) - target_include_directories(lib_objs SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) + target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) +else() + target_include_directories(lib_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) endif() -target_include_directories(lib_objs SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/) -target_include_directories(lib_objs SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/) +target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/) +target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/) if (HAVE_RULES) target_include_directories(lib_objs SYSTEM PRIVATE ${PCRE_INCLUDE}) endif() @@ -49,3 +50,10 @@ endif() if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) target_precompile_headers(lib_objs PRIVATE precompiled.h) endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # -Wfloat-equal is generated by picojson.h + set_source_files_properties(cppcheck.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal) + set_source_files_properties(importproject.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal) + set_source_files_properties(settings.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal) +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0b5f776a9..894fb7d0b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,6 +10,8 @@ if (BUILD_TESTS) target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/cli/) if(USE_BUNDLED_TINYXML2) target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2) + else() + target_include_directories(testrunner SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) endif() target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/) if (HAVE_RULES)