summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2022-08-09 00:21:00 +0200
committerAlbert Astals Cid <aacid@kde.org>2022-08-09 00:21:00 +0200
commitb8aaf51d69938412f9cca215d3825f53931706d6 (patch)
tree001563b9676cdee9c5b58ee669202b29edfa0ca6
parent6ea5c63b7d8a1728f178b3a5d377bca3a17f7447 (diff)
Workaround cmake 3.24.0 warning-y code
https://gitlab.kitware.com/cmake/cmake/-/issues/23823
-rw-r--r--.gitlab-ci.yml6
-rw-r--r--CMakeLists.txt6
-rw-r--r--qt5/tests/CMakeLists.txt24
-rw-r--r--qt6/tests/CMakeLists.txt24
4 files changed, 56 insertions, 4 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a067dc65..237283a6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -46,7 +46,6 @@ build:
build_clang14_libcpp:
stage: build
- image: debian:bookworm
script:
- echo "We want to compile with C++23 here because it has some nice things like deleted std::string nullptr constructor"
- sed -i -e "s@CMAKE_CXX_STANDARD 17@CMAKE_CXX_STANDARD 23@g" CMakeLists.txt
@@ -91,12 +90,11 @@ build_mingw64_fedora36:
build_clazy_clang14:
stage: build
- image: debian:bookworm
script:
- apt-get install --yes --no-install-recommends clazy clang-14
- mkdir -p build && cd build
- - CC=clang-14 CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -G Ninja ..
- - CLAZY_CHECKS="level0,level1,level2,isempty-vs-count,qhash-with-char-pointer-key,tr-non-literal,no-non-pod-global-static" ninja
+ - CC=clang-14 CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -G Ninja -DADD_CLAZY_FLAGS=ON ..
+ - ninja
build_android:
stage: build
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b00618d8..29709809 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,6 +87,7 @@ else()
set(ENABLE_RELOCATABLE OFF)
endif()
option(EXTRA_WARN "Enable extra compile warnings" OFF)
+option(ADD_CLAZY_FLAGS "Enable clazy compile warnings" OFF)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
@@ -131,6 +132,11 @@ else()
message(FATAL_ERROR "Invalid font configuration setting: ${FONT_CONFIGURATION}")
endif()
+if(ADD_CLAZY_FLAGS)
+ set(DEFAULT_CLAZY_FLAGS "SHELL:-Xclang -plugin-arg-clazy" "SHELL:-Xclang level2,isempty-vs-count,qhash-with-char-pointer-key,tr-non-literal,no-non-pod-global-static")
+ add_compile_options(${DEFAULT_CLAZY_FLAGS})
+endif()
+
# Enable these unconditionally.
set(OPI_SUPPORT ON)
set(TEXTOUT_WORD_LIST ON)
diff --git a/qt5/tests/CMakeLists.txt b/qt5/tests/CMakeLists.txt
index baadd428..adc38117 100644
--- a/qt5/tests/CMakeLists.txt
+++ b/qt5/tests/CMakeLists.txt
@@ -14,6 +14,18 @@ macro(QT5_ADD_SIMPLETEST exe source)
)
poppler_add_test(${exe} BUILD_QT5_TESTS ${${test_name}_SOURCES})
target_link_libraries(${exe} poppler-qt5 Qt5::Widgets)
+
+ if (ADD_CLAZY_FLAGS)
+ # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/23823
+ get_target_property(TARGET_FLAGS ${exe} COMPILE_OPTIONS)
+ string(REPLACE "${DEFAULT_CLAZY_FLAGS}" "" TARGET_FLAGS "${TARGET_FLAGS}")
+ set_target_properties(${exe} PROPERTIES COMPILE_OPTIONS "${TARGET_FLAGS}")
+ endif()
+
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/23823
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${exe}_autogen/mocs_compilation.cpp PROPERTIES COMPILE_FLAGS "-Wno-weak-vtables")
+ endif()
endmacro(QT5_ADD_SIMPLETEST)
macro(QT5_ADD_QTEST exe source)
@@ -25,6 +37,18 @@ macro(QT5_ADD_QTEST exe source)
poppler_add_test(${exe} BUILD_QT5_TESTS ${${test_name}_SOURCES})
add_test(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
target_link_libraries(${exe} poppler-qt5 Qt5::Widgets Qt5::Test Qt5::Core Qt5::Gui)
+
+ if (ADD_CLAZY_FLAGS)
+ # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/23823
+ get_target_property(TARGET_FLAGS ${exe} COMPILE_OPTIONS)
+ string(REPLACE "${DEFAULT_CLAZY_FLAGS}" "" TARGET_FLAGS "${TARGET_FLAGS}")
+ set_target_properties(${exe} PROPERTIES COMPILE_OPTIONS "${TARGET_FLAGS}")
+ endif()
+
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/23823
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${exe}_autogen/mocs_compilation.cpp PROPERTIES COMPILE_FLAGS "-Wno-weak-vtables")
+ endif()
endif ()
endmacro(QT5_ADD_QTEST)
diff --git a/qt6/tests/CMakeLists.txt b/qt6/tests/CMakeLists.txt
index d5f7184f..efa899a0 100644
--- a/qt6/tests/CMakeLists.txt
+++ b/qt6/tests/CMakeLists.txt
@@ -14,6 +14,18 @@ macro(QT6_ADD_SIMPLETEST exe source)
)
poppler_add_test(${exe} BUILD_QT6_TESTS ${${test_name}_SOURCES})
target_link_libraries(${exe} poppler-qt6 Qt6::Widgets)
+
+ if (ADD_CLAZY_FLAGS)
+ # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/23823
+ get_target_property(TARGET_FLAGS ${exe} COMPILE_OPTIONS)
+ string(REPLACE "${DEFAULT_CLAZY_FLAGS}" "" TARGET_FLAGS "${TARGET_FLAGS}")
+ set_target_properties(${exe} PROPERTIES COMPILE_OPTIONS "${TARGET_FLAGS}")
+ endif()
+
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/23823
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${exe}_autogen/mocs_compilation.cpp PROPERTIES COMPILE_FLAGS "-Wno-weak-vtables")
+ endif()
endmacro()
macro(QT6_ADD_QTEST exe source)
@@ -24,6 +36,18 @@ macro(QT6_ADD_QTEST exe source)
poppler_add_test(${exe} BUILD_QT6_TESTS ${${test_name}_SOURCES})
add_test(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
target_link_libraries(${exe} poppler-qt6 Qt6::Widgets Qt6::Test Qt6::Gui)
+
+ if (ADD_CLAZY_FLAGS)
+ # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/23823
+ get_target_property(TARGET_FLAGS ${exe} COMPILE_OPTIONS)
+ string(REPLACE "${DEFAULT_CLAZY_FLAGS}" "" TARGET_FLAGS "${TARGET_FLAGS}")
+ set_target_properties(${exe} PROPERTIES COMPILE_OPTIONS "${TARGET_FLAGS}")
+ endif()
+
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/23823
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${exe}_autogen/mocs_compilation.cpp PROPERTIES COMPILE_FLAGS "-Wno-weak-vtables")
+ endif()
endmacro()