From 185570e85073d2885c2f628ccd5a93134c04e733 Mon Sep 17 00:00:00 2001 From: adam-ce <5292991+adam-ce@users.noreply.github.com> Date: Fri, 17 Jul 2026 15:36:09 +0200 Subject: [PATCH 1/3] ci: Treat compiler warnings as errors --- .github/workflows/ci.yml | 1 + CMakeLists.txt | 1 + src/terrainlib/CMakeLists.txt | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f5e926..c1c3678 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,6 +122,7 @@ jobs: -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + -DALP_WARNINGS_AS_ERRORS=ON ${{ matrix.cmake_flags }} - name: Save installed CMake dependencies diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c2a966..fc289e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ option(ALP_ENABLE_THREAD_SANITIZER "Compile with ThreadSanitizer enabled" OFF) option(ALP_ENABLE_ADDRESS_SANITIZER "Compile with AddressSanitizer enabled" OFF) option(ALP_ENABLE_OVERVIEW_READING "Enable GDAL overview reading (broken with newer GDAL versions)" OFF) option(ALP_ENABLE_UNITY_BUILD "Enable unity (jumbo) builds to speed compilation" OFF) +option(ALP_WARNINGS_AS_ERRORS "Treat first-party compiler warnings as errors" OFF) set(ALP_ENABLE_ASSERTS_DEFAULT OFF) if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") diff --git a/src/terrainlib/CMakeLists.txt b/src/terrainlib/CMakeLists.txt index c9a0c1c..79dd32d 100644 --- a/src/terrainlib/CMakeLists.txt +++ b/src/terrainlib/CMakeLists.txt @@ -54,6 +54,12 @@ target_compile_features(terrainlib PUBLIC cxx_std_23) target_compile_definitions(terrainlib PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE) target_include_directories(terrainlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_precompile_headers(terrainlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/pch.h) +if(ALP_WARNINGS_AS_ERRORS) + target_compile_options(terrainlib PUBLIC + $<$:-Werror> + $<$:/WX> + ) +endif() target_link_libraries(terrainlib PUBLIC radix ZLIB::ZLIB From a93e6b66d2819c6212941c571b685226145da302 Mon Sep 17 00:00:00 2001 From: adam-ce <5292991+adam-ce@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:03:07 +0200 Subject: [PATCH 2/3] Fix compiler warnings and expand GCC CI coverage Disable warnings-as-errors for GCC 14 because its remaining dependency warnings are false positives and cannot be resolved in project code. Add GCC 15 and GCC 16 warnings-as-errors jobs to verify whether newer compiler versions have fixed these diagnostics. --- .github/workflows/ci.yml | 27 ++++++++++++++++++- src/CMakeLists.txt | 4 +-- src/sf_browser/core/window/Window.cpp | 2 +- src/sf_browser/core/window/Window.h | 2 +- src/sf_merger/merge/NodeData.h | 4 +-- src/terrainlib/Dataset.cpp | 6 ++--- src/terrainlib/mesh/io/gltf.cpp | 20 +++----------- src/terrainlib/mesh/topology.inl | 1 + src/terrainlib/mesh/validate.cpp | 36 +++++++++++++------------- src/terrainlib/octree/storage/open.inl | 2 +- src/terrainlib/uv/unwrap.cpp | 8 +++--- unittests/terrainlib/fixed_vector.cpp | 5 ++-- 12 files changed, 66 insertions(+), 51 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1c3678..d680618 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,24 +22,42 @@ jobs: cxx: g++-14 build_type: Release sanitizer: normal + warnings_as_errors: OFF + cmake_flags: "" + - name: gcc-15-normal + cc: gcc-15 + cxx: g++-15 + build_type: Release + sanitizer: normal + warnings_as_errors: ON + cmake_flags: "" + - name: gcc-16-normal + cc: gcc-16 + cxx: g++-16 + build_type: Release + sanitizer: normal + warnings_as_errors: ON cmake_flags: "" - name: clang-23-asan cc: clang-23 cxx: clang++-23 build_type: RelWithDebInfo sanitizer: asan + warnings_as_errors: ON cmake_flags: -DALP_ENABLE_ADDRESS_SANITIZER=ON - name: clang-23-tsan cc: clang-23 cxx: clang++-23 build_type: RelWithDebInfo sanitizer: tsan + warnings_as_errors: ON cmake_flags: -DALP_ENABLE_THREAD_SANITIZER=ON - name: clang-23-unity cc: clang-23 cxx: clang++-23 build_type: Release sanitizer: normal + warnings_as_errors: ON cmake_flags: -DALP_ENABLE_UNITY_BUILD=ON steps: @@ -82,6 +100,13 @@ jobs: sudo /tmp/llvm.sh 23 sudo apt-get install -y --no-install-recommends libclang-rt-23-dev + - name: Install GCC ${{ matrix.cxx }} + if: matrix.cxx == 'g++-15' || matrix.cxx == 'g++-16' + run: | + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install -y --no-install-recommends ${{ matrix.cc }} ${{ matrix.cxx }} + - name: Restore installed CMake dependencies id: cmake_dependency_cache uses: actions/cache/restore@v4 @@ -122,7 +147,7 @@ jobs: -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - -DALP_WARNINGS_AS_ERRORS=ON + -DALP_WARNINGS_AS_ERRORS=${{ matrix.warnings_as_errors }} ${{ matrix.cmake_flags }} - name: Save installed CMake dependencies diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5ece70b..e8d11f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,7 +22,7 @@ find_package(CGAL REQUIRED) include(../cmake/SetupOpenCV.cmake) alp_setup_opencv(4.11.0) -alp_add_git_repository(cgltf URL https://github.com/jkuhlmann/cgltf COMMITISH 7331a5adf4b0fde15f0e682a5803e4f17137e0ad DO_NOT_ADD_SUBPROJECT) +alp_add_git_repository(cgltf URL https://github.com/AlpineMapsOrgDependencies/cgltf.git COMMITISH e035b820ccde6ab20451b612d8033c9b76ea0ce4 DO_NOT_ADD_SUBPROJECT) add_library(cgltf INTERFACE) target_include_directories(cgltf SYSTEM INTERFACE ${cgltf_SOURCE_DIR}) @@ -42,7 +42,7 @@ target_include_directories(tl_expected SYSTEM INTERFACE ${tl_expected_SOURCE_DIR set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "SPDLOG_FMT_EXTERNAL" FORCE) alp_add_git_repository(spdlog URL https://github.com/gabime/spdlog.git COMMITISH v1.17.0) -alp_add_git_repository(zpp_bits URL https://github.com/eyalz800/zpp_bits.git COMMITISH v4.7.2 DO_NOT_ADD_SUBPROJECT) +alp_add_git_repository(zpp_bits URL https://github.com/eyalz800/zpp_bits.git COMMITISH v4.7.3 DO_NOT_ADD_SUBPROJECT) add_library(zpp_bits INTERFACE) target_include_directories(zpp_bits SYSTEM INTERFACE ${zpp_bits_SOURCE_DIR}) diff --git a/src/sf_browser/core/window/Window.cpp b/src/sf_browser/core/window/Window.cpp index f3d04f2..66b011c 100644 --- a/src/sf_browser/core/window/Window.cpp +++ b/src/sf_browser/core/window/Window.cpp @@ -5,7 +5,7 @@ std::atomic Window::glfw_initialized(false); std::atomic Window::window_instances(0); -Window::Window(WindowConfig config) : m_width(config.width), m_height(config.height), m_title(config.title), m_msaa_samples(config.msaa_samples) { +Window::Window(WindowConfig config) : m_width(config.width), m_height(config.height), m_title(config.title) /*, m_msaa_samples(config.msaa_samples)*/ { update_window_count(1); const auto [gl_major_version, gl_minor_version] = config.opengl_version; diff --git a/src/sf_browser/core/window/Window.h b/src/sf_browser/core/window/Window.h index 4d6703d..fe090a1 100644 --- a/src/sf_browser/core/window/Window.h +++ b/src/sf_browser/core/window/Window.h @@ -58,7 +58,7 @@ class Window { int m_width, m_height, m_max_dimension, m_min_dimension; std::string m_title; - int m_msaa_samples; + // int m_msaa_samples; GLFWwindow* m_handle; diff --git a/src/sf_merger/merge/NodeData.h b/src/sf_merger/merge/NodeData.h index f280d2b..c3c9de1 100644 --- a/src/sf_merger/merge/NodeData.h +++ b/src/sf_merger/merge/NodeData.h @@ -27,7 +27,7 @@ class NodeData { // Status::Leaf or Status::Inner guarantuess a node is present template - std::enable_if_t + std::enable_if_t mesh() const { auto mesh = this->load_mesh(); if (mesh.has_value()) { @@ -39,7 +39,7 @@ class NodeData { // Status::Missing and Status::Virtual do not exist on disk, but may be the child of a leaf or inner node template - std::enable_if_t>> + std::enable_if_t>> mesh() const { return this->load_mesh(); } diff --git a/src/terrainlib/Dataset.cpp b/src/terrainlib/Dataset.cpp index 6542e68..4309896 100644 --- a/src/terrainlib/Dataset.cpp +++ b/src/terrainlib/Dataset.cpp @@ -49,21 +49,21 @@ void GdalDatasetDeleter::operator()(GDALDataset *dataset) const { std::optional Dataset::open_raster(std::filesystem::path path) { if (GDALDataset *dataset = open_gdal_dataset(path, GDAL_OF_RASTER)) { - return std::optional(std::move(Dataset(path, dataset))); + return std::optional(Dataset(path, dataset)); } LOG_ERROR("Couldn't open raster dataset {}.\n", path); return std::nullopt; } std::optional Dataset::open_vector(std::filesystem::path path) { if (GDALDataset *dataset = open_gdal_dataset(path, GDAL_OF_VECTOR)) { - return std::optional(std::move(Dataset(path, dataset))); + return std::optional(Dataset(path, dataset)); } LOG_ERROR("Couldn't open vector dataset {}.\n", path); return std::nullopt; } std::optional> Dataset::open_shared_raster(std::filesystem::path path) { if (GDALDataset *dataset = open_gdal_dataset(path, GDAL_OF_RASTER)) { - return std::make_shared(std::move(Dataset(path, dataset))); + return std::make_shared(Dataset(path, dataset)); } LOG_ERROR("Couldn't open shared raster dataset {}.\n", path); return std::nullopt; diff --git a/src/terrainlib/mesh/io/gltf.cpp b/src/terrainlib/mesh/io/gltf.cpp index bb01bb4..3616096 100644 --- a/src/terrainlib/mesh/io/gltf.cpp +++ b/src/terrainlib/mesh/io/gltf.cpp @@ -20,18 +20,6 @@ using namespace mesh::io::utils; namespace mesh::io::gltf { namespace { -const int GL_NEAREST = 0x2600; -const int GL_LINEAR = 0x2601; -const int GL_NEAREST_MIPMAP_NEAREST = 0x2700; -const int GL_LINEAR_MIPMAP_NEAREST = 0x2701; -const int GL_NEAREST_MIPMAP_LINEAR = 0x2702; -const int GL_LINEAR_MIPMAP_LINEAR = 0x2703; -const int GL_TEXTURE_MAG_FILTER = 0x2800; -const int GL_TEXTURE_MIN_FILTER = 0x2801; -const int GL_REPEAT = 0x2901; -const int GL_CLAMP_TO_EDGE = 0x812F; -const int GL_MIRRORED_REPEAT = 0x8370; - cgltf_attribute *find_attribute_with_type(cgltf_attribute *attributes, size_t attribute_count, cgltf_attribute_type type) { for (unsigned int i = 0; i < attribute_count; i++) { cgltf_attribute *attribute = &attributes[i]; @@ -575,10 +563,10 @@ tl::expected save_to_path( std::array samplers; cgltf_sampler &sampler = samplers[0] = {}; - sampler.min_filter = GL_LINEAR_MIPMAP_LINEAR; - sampler.mag_filter = GL_LINEAR; - sampler.wrap_s = GL_CLAMP_TO_EDGE; - sampler.wrap_t = GL_CLAMP_TO_EDGE; + sampler.min_filter = cgltf_filter_type_linear_mipmap_linear; + sampler.mag_filter = cgltf_filter_type_linear; + sampler.wrap_s = cgltf_wrap_mode_clamp_to_edge; + sampler.wrap_t = cgltf_wrap_mode_clamp_to_edge; std::array textures; cgltf_texture &texture = textures[0] = {}; diff --git a/src/terrainlib/mesh/topology.inl b/src/terrainlib/mesh/topology.inl index 5c85e9e..d27cb62 100644 --- a/src/terrainlib/mesh/topology.inl +++ b/src/terrainlib/mesh/topology.inl @@ -108,6 +108,7 @@ inline constexpr glm::uvec3 change_vertex(const glm::uvec3 &triangle, const uint } else if (!allow_missing) { UNREACHABLE(); } + return triangle; } inline constexpr void flip_triangle_orientation(glm::uvec3 &triangle) { diff --git a/src/terrainlib/mesh/validate.cpp b/src/terrainlib/mesh/validate.cpp index b4e8fa1..0fd7c4e 100644 --- a/src/terrainlib/mesh/validate.cpp +++ b/src/terrainlib/mesh/validate.cpp @@ -21,29 +21,29 @@ namespace mesh { namespace { -inline constexpr double EPSILON = 1e-12; +// inline constexpr double EPSILON = 1e-12; constexpr bool has_flag(const ValidationFlags set, const ValidationFlags flag) noexcept { return (set & flag) != ValidationFlags::None; } -inline bool has_duplicate_faces(const std::span triangles, const bool ignore_orientation = true) { - std::unordered_map counts; - counts.reserve(triangles.size()); - - for (const glm::uvec3 &triangle : triangles) { - const glm::uvec3 normalized = normalize_triangle(triangle, !ignore_orientation); - counts[normalized] += 1; - } - - for (const auto &[_triangle, count] : counts) { - if (count > 1) { - return true; - } - } - - return false; -} +// inline bool has_duplicate_faces(const std::span triangles, const bool ignore_orientation = true) { +// std::unordered_map counts; +// counts.reserve(triangles.size()); +// +// for (const glm::uvec3 &triangle : triangles) { +// const glm::uvec3 normalized = normalize_triangle(triangle, !ignore_orientation); +// counts[normalized] += 1; +// } +// +// for (const auto &[_triangle, count] : counts) { +// if (count > 1) { +// return true; +// } +// } +// +// return false; +// } template void validate_impl_basic(const mesh::View_ &mesh) { diff --git a/src/terrainlib/octree/storage/open.inl b/src/terrainlib/octree/storage/open.inl index a7cfdb9..e0c9b0d 100644 --- a/src/terrainlib/octree/storage/open.inl +++ b/src/terrainlib/octree/storage/open.inl @@ -82,7 +82,7 @@ Storage_ open_folder( LOG_WARN("Unable to determine layout of dataset, using layout strategy {} and extension {}", disk::layout::StrategyRegister::instance().get_id(*default_layout_strategy), default_extension_with_dot); - layout_info_opt = std::move(octree::helpers::LayoutWithoutBase(std::move(default_layout_strategy), default_extension_with_dot)); + layout_info_opt = octree::helpers::LayoutWithoutBase(std::move(default_layout_strategy), default_extension_with_dot); } disk::Layout layout(base_path, std::move(layout_info_opt->strategy), layout_info_opt->extension_with_dot); diff --git a/src/terrainlib/uv/unwrap.cpp b/src/terrainlib/uv/unwrap.cpp index 5e61092..d162137 100644 --- a/src/terrainlib/uv/unwrap.cpp +++ b/src/terrainlib/uv/unwrap.cpp @@ -139,25 +139,25 @@ tl::expected parameterize_mesh(cgal::Mesh &mesh, Algorit if (algorithm == Algorithm::TutteBarycentricMapping) { if (border == Border::Circle) { result = CGAL::Surface_mesh_parameterization::parameterize(mesh, TutteBarycentricMappingParameterizerCircularBorder(), bhd, uv_map); - } else if (border == Border::Square) { + } else { result = CGAL::Surface_mesh_parameterization::parameterize(mesh, TutteBarycentricMappingParameterizerSquareBorder(), bhd, uv_map); } } else if (algorithm == Algorithm::DiscreteAuthalic) { if (border == Border::Circle) { result = CGAL::Surface_mesh_parameterization::parameterize(mesh, DiscreteAuthalicParameterizerCircularBorder(), bhd, uv_map); - } else if (border == Border::Square) { + } else { result = CGAL::Surface_mesh_parameterization::parameterize(mesh, DiscreteAuthalicParameterizerSquareBorder(), bhd, uv_map); } } else if (algorithm == Algorithm::DiscreteConformalMap) { if (border == Border::Circle) { result = CGAL::Surface_mesh_parameterization::parameterize(mesh, DiscreteConformalMapParameterizerCircularBorder(), bhd, uv_map); - } else if (border == Border::Square) { + } else { result = CGAL::Surface_mesh_parameterization::parameterize(mesh, DiscreteConformalMapParameterizerSquareBorder(), bhd, uv_map); } } else if (algorithm == Algorithm::FloaterMeanValueCoordinates) { if (border == Border::Circle) { result = CGAL::Surface_mesh_parameterization::parameterize(mesh, FloaterMeanValueCoordinatesParameterizerCircularBorder(), bhd, uv_map); - } else if (border == Border::Square) { + } else { result = CGAL::Surface_mesh_parameterization::parameterize(mesh, FloaterMeanValueCoordinatesParameterizerSquareBorder(), bhd, uv_map); } } else if (algorithm == Algorithm::LeastSquaresConformalMap) { diff --git a/unittests/terrainlib/fixed_vector.cpp b/unittests/terrainlib/fixed_vector.cpp index 6e841aa..3f67b24 100644 --- a/unittests/terrainlib/fixed_vector.cpp +++ b/unittests/terrainlib/fixed_vector.cpp @@ -30,8 +30,9 @@ TEST_CASE("FixedVector copy constructor and assignment") { REQUIRE(assign_vec.size() == vec.size()); CHECK(assign_vec[2] == 3); - // Self-assignment - vec = vec; + // Exercise self-assignment through an alias to avoid Clang's syntactic self-assignment warning. + const auto *self = &vec; + vec = *self; CHECK(vec.size() == 3); } From e020ee3f1ac5d7aad568362ba96cc15fb79ebf54 Mon Sep 17 00:00:00 2001 From: adam-ce <5292991+adam-ce@users.noreply.github.com> Date: Mon, 20 Jul 2026 19:09:52 +0200 Subject: [PATCH 3/3] Remove GCC 15 from CI matrix --- .github/workflows/ci.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d680618..d4f2e89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,13 +24,6 @@ jobs: sanitizer: normal warnings_as_errors: OFF cmake_flags: "" - - name: gcc-15-normal - cc: gcc-15 - cxx: g++-15 - build_type: Release - sanitizer: normal - warnings_as_errors: ON - cmake_flags: "" - name: gcc-16-normal cc: gcc-16 cxx: g++-16 @@ -101,7 +94,7 @@ jobs: sudo apt-get install -y --no-install-recommends libclang-rt-23-dev - name: Install GCC ${{ matrix.cxx }} - if: matrix.cxx == 'g++-15' || matrix.cxx == 'g++-16' + if: matrix.cxx == 'g++-16' run: | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update