Skip to content

Commit 691184e

Browse files
committed
add unit build support [ci build]
1 parent 779260a commit 691184e

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmake_minimum_required(VERSION 3.15.0) # minimum imposed by scikit-build-core
22
project(polyscope LANGUAGES CXX)
33

4+
option(POLYSCOPE_PY_UNITY_BUILD "Enable Unity builds" OFF)
45

56
## Gather dependencies
67

@@ -37,7 +38,25 @@ set_target_properties(polyscope_bindings PROPERTIES CXX_VISIBILITY_PRESET "defau
3738
target_include_directories(polyscope_bindings PUBLIC "${EIGEN3_INCLUDE_DIR}")
3839
target_link_libraries(polyscope_bindings PRIVATE polyscope)
3940

40-
# make the resulting target actually be called polyscope, without the py
41-
# set_target_properties(polyscope_py PROPERTIES OUTPUT_NAME polyscope)
41+
if(POLYSCOPE_PY_UNITY_BUILD)
42+
43+
# NOTE: these are not perfect, sometimes the explicit template
44+
# instantiations get messed up and cause compile errors. The current
45+
# batch sizes were chosen because they happen to work around that.
46+
#
47+
# However, this does give a nearly 50% speedup, so it can be worth using
48+
# for long-running CI builds.
49+
50+
set_target_properties(polyscope PROPERTIES
51+
UNITY_BUILD ON
52+
UNITY_BUILD_BATCH_SIZE 5
53+
)
54+
55+
set_target_properties(polyscope_bindings PROPERTIES
56+
UNITY_BUILD ON
57+
UNITY_BUILD_BATCH_SIZE 4
58+
)
59+
60+
endif()
4261

4362
install(TARGETS polyscope_bindings LIBRARY DESTINATION .)

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ build-backend = "scikit_build_core.build"
3333

3434
[tool.scikit-build]
3535
build.verbose = true
36-
logging.level = "INFO"
36+
logging.level = "INFO"
37+
38+
[tool.cibuildwheel]
39+
# for cibuildwheel only, use unity builds by default
40+
environment = {POLYSCOPE_PY_UNITY_BUILD="ON"}

0 commit comments

Comments
 (0)