Skip to content

Commit 7d37197

Browse files
FIX compas.h header reduction and CMakeLists flag for PCH.
1 parent d8224f4 commit 7d37197

File tree

13 files changed

+93
-101
lines changed

13 files changed

+93
-101
lines changed

CMakeLists.txt

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ project(cgal_wrapper LANGUAGES CXX)
44
set(CMAKE_CXX_STANDARD 20)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
7+
set(CMAKE_BUILD_TYPE Release)
8+
set(CMAKE_CXX_FLAGS_DEBUG "")
9+
10+
# =====================================================================
11+
# Set this flag to ON for developing to reduce build time.
12+
# Set this flag to OFF for publishing for file size reduction.
13+
# =====================================================================
14+
option(ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers for the build" OFF)
15+
16+
# =====================================================================
17+
# Build size reduction.
18+
# =====================================================================
19+
20+
if (NOT ENABLE_PRECOMPILED_HEADERS)
21+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
22+
if(MSVC)
23+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O1") # Optimize for size on MSVC
24+
else()
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os") # Optimize for size on GCC/Clang
26+
endif()
27+
endif()
728

829
# =====================================================================
930
# Dependencies
@@ -196,15 +217,17 @@ target_include_directories(compas_cgal_ext PRIVATE
196217
# Make sure external dependencies are downloaded before building the extension
197218
add_dependencies(compas_cgal_ext external_downloads)
198219

199-
# Enhanced PCH configuration
200-
set(CMAKE_PCH_INSTANTIATE_TEMPLATES OFF)
201-
set(CMAKE_PCH_WARN_INVALID OFF)
220+
if (ENABLE_PRECOMPILED_HEADERS)
221+
# Enhanced PCH configuration
222+
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
223+
set(CMAKE_PCH_WARN_INVALID ON)
202224

203-
# Configure PCH for the extension
204-
target_precompile_headers(compas_cgal_ext
205-
PRIVATE
206-
src/compas.h
207-
)
225+
# Configure PCH for the extension
226+
target_precompile_headers(compas_cgal_ext
227+
PRIVATE
228+
src/compas.h
229+
)
230+
endif()
208231

209232
# Install directive for scikit-build-core
210233
install(TARGETS compas_cgal_ext LIBRARY DESTINATION compas_cgal)

src/booleans.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
#include "compas.h"
44

5+
// CGAL boolean
6+
#include <CGAL/Polygon_mesh_processing/corefinement.h>
7+
#include <CGAL/Polygon_mesh_processing/clip.h>
8+
59
/**
610
* Compute the boolean union of two triangle meshes.
711
*

src/compas.h

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,12 @@
55
// This file is referenced in CMakeLists PCH section.
66

77
// STD
8-
#include <stdlib.h>
98
#include <vector>
10-
#include <array>
11-
#include <map>
12-
#include <cstdlib>
13-
#include <ctime>
14-
#include <iomanip>
15-
#include <algorithm>
16-
#include <unordered_map>
17-
#include <numeric>
18-
#include <limits>
19-
#include <chrono>
20-
#include <float.h>
21-
#include <inttypes.h>
22-
#include <cstring>
23-
#include <set>
24-
#include <unordered_set>
25-
#include <list>
26-
#include <string>
27-
#include <fstream>
28-
#include <sstream>
29-
#include <iostream>
30-
#include <filesystem>
31-
#include <utility>
32-
339

3410
// Nanobind
3511
#include <nanobind/nanobind.h>
3612
#include <nanobind/eigen/dense.h>
3713
#include <nanobind/eigen/sparse.h>
38-
#include <nanobind/ndarray.h>
39-
#include <nanobind/stl/array.h>
4014
#include <nanobind/stl/tuple.h>
4115
#include <nanobind/stl/bind_vector.h>
4216
#include <nanobind/stl/shared_ptr.h>
@@ -49,7 +23,6 @@ using namespace nb::literals; // enables syntax for annotating function and argu
4923
#include <boost/multiprecision/cpp_dec_float.hpp>
5024
#include <boost/multiprecision/cpp_int.hpp>
5125

52-
5326
// Eigen
5427
#include <Eigen/Core>
5528
#include <Eigen/Dense>
@@ -62,67 +35,6 @@ using namespace nb::literals; // enables syntax for annotating function and argu
6235
#include <CGAL/Polyhedron_incremental_builder_3.h>
6336
#include <CGAL/Polyhedron_items_with_id_3.h>
6437

65-
// CGAL remesh
66-
#include <CGAL/Polygon_mesh_processing/remesh.h>
67-
#include <CGAL/Polygon_mesh_processing/detect_features.h>
68-
69-
// CGAL measure
70-
#include <CGAL/Polygon_mesh_processing/measure.h>
71-
#include <CGAL/Point_3.h>
72-
73-
// CGAL boolean
74-
#include <CGAL/Polygon_mesh_processing/corefinement.h>
75-
#include <CGAL/Polygon_mesh_processing/clip.h>
76-
77-
// CGAL intersection
78-
#include <CGAL/Polygon_mesh_processing/intersection.h>
79-
80-
// CGAL reconstruction
81-
#include <CGAL/poisson_surface_reconstruction.h>
82-
#include <CGAL/property_map.h>
83-
#include <CGAL/remove_outliers.h>
84-
#include <CGAL/compute_average_spacing.h>
85-
#include <CGAL/pca_estimate_normals.h>
86-
#include <CGAL/mst_orient_normals.h>
87-
#include <CGAL/property_map.h>
88-
#include <CGAL/jet_smooth_point_set.h>
89-
#include <CGAL/Point_set_3.h>
90-
#include <CGAL/grid_simplify_point_set.h>
91-
92-
// CGAL skeletonization
93-
#include <CGAL/Mean_curvature_flow_skeletonization.h>
94-
#include <CGAL/boost/graph/split_graph_into_polylines.h>
95-
96-
// CGAL slicer
97-
#include <CGAL/Polygon_mesh_slicer.h>
98-
99-
// CGAL subdivision
100-
#include <CGAL/subdivision_method_3.h>
101-
102-
// CGAL triangulation
103-
#include <CGAL/Delaunay_triangulation_2.h>
104-
#include <CGAL/Constrained_triangulation_2.h>
105-
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
106-
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
107-
#include <CGAL/Triangulation_face_base_with_info_2.h>
108-
#include <CGAL/Polygon_2.h>
109-
#include <CGAL/Delaunay_mesher_2.h>
110-
#include <CGAL/Delaunay_mesh_vertex_base_2.h>
111-
#include <CGAL/Delaunay_mesh_face_base_2.h>
112-
#include <CGAL/Delaunay_mesh_size_criteria_2.h>
113-
#include <CGAL/Triangulation_conformer_2.h>
114-
#include <CGAL/lloyd_optimize_mesh_2.h>
115-
116-
// CGAL straight skeleton 2
117-
#include <CGAL/Polygon_2.h>
118-
#include <CGAL/create_straight_skeleton_2.h>
119-
#include <CGAL/create_straight_skeleton_from_polygon_with_holes_2.h>
120-
#include <CGAL/create_offset_polygons_2.h>
121-
#include <CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h>
122-
#include <CGAL/create_weighted_straight_skeleton_2.h>
123-
#include <CGAL/create_offset_polygons_from_polygon_with_holes_2.h>
124-
125-
12638
namespace compas
12739
{
12840
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;

src/intersections.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
#include "compas.h"
44

5+
// CGAL intersection
6+
#include <CGAL/Polygon_mesh_processing/intersection.h>
7+
58
/**
69
* Compute intersection between two triangle meshes.
710
*

src/measure.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pmp_volume(
1717
{
1818
compas::Mesh mesh = compas::mesh_from_vertices_and_faces(vertices, faces);
1919
double volume = CGAL::Polygon_mesh_processing::volume(mesh);
20+
int a = 0;
2021
return volume;
2122
}
2223

src/measure.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
#include "compas.h"
44

5+
// CGAL measure
6+
#include <CGAL/Polygon_mesh_processing/measure.h>
7+
#include <CGAL/Point_3.h>
8+
59
/**
610
* @brief Computes the surface area of a triangle mesh.
711
*

src/meshing.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
/**
2-
* @file meshing.h
3-
* @brief Header file for mesh processing operations using CGAL
4-
*/
5-
61
#pragma once
72

83
#include "compas.h"
94

5+
// CGAL remesh
6+
#include <CGAL/Polygon_mesh_processing/remesh.h>
7+
#include <CGAL/Polygon_mesh_processing/detect_features.h>
8+
109
namespace compas {
1110

1211
/**

src/reconstruction.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
#include "compas.h"
44

5+
// CGAL reconstruction
6+
#include <CGAL/poisson_surface_reconstruction.h>
7+
#include <CGAL/property_map.h>
8+
#include <CGAL/remove_outliers.h>
9+
#include <CGAL/compute_average_spacing.h>
10+
#include <CGAL/pca_estimate_normals.h>
11+
#include <CGAL/mst_orient_normals.h>
12+
#include <CGAL/property_map.h>
13+
#include <CGAL/jet_smooth_point_set.h>
14+
#include <CGAL/Point_set_3.h>
15+
#include <CGAL/grid_simplify_point_set.h>
16+
517
/**
618
* @brief Perform Poisson surface reconstruction on an oriented pointcloud with normals.
719
*

src/skeletonization.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
#include "compas.h"
44

5+
// CGAL skeletonization
6+
#include <CGAL/Mean_curvature_flow_skeletonization.h>
7+
#include <CGAL/boost/graph/split_graph_into_polylines.h>
8+
59
/**
610
* @brief Compute the geometric skeleton of a triangle mesh using mean curvature flow.
711
*

src/slicer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
#include "compas.h"
44

5+
// CGAL slicer
6+
#include <CGAL/Polygon_mesh_slicer.h>
7+
58
/**
69
* @brief Slice a mesh with a set of planes defined by points and normals.
710
*

0 commit comments

Comments
 (0)