mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
CMAKE: add unity builds support
This commit is contained in:
parent
d974477e40
commit
555013cdda
@ -464,6 +464,16 @@ function(vtkm_library)
|
||||
set(VTKm_LIB_type SHARED)
|
||||
endif()
|
||||
|
||||
# Skip unity builds unless explicitly asked
|
||||
foreach(source IN LISTS VTKm_LIB_SOURCES VTKm_LIB_DEVICE_SOURCES)
|
||||
get_source_file_property(is_candidate ${source} UNITY_BUILD_CANDIDATE)
|
||||
if (NOT is_candidate)
|
||||
list(APPEND non_unity_sources ${source})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set_source_files_properties(${non_unity_sources} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
|
||||
add_library(${lib_name}
|
||||
${VTKm_LIB_type}
|
||||
${VTKm_LIB_SOURCES}
|
||||
@ -615,8 +625,10 @@ function(vtkm_add_instantiations instantiations_list)
|
||||
math(EXPR counter "${counter} + 1")
|
||||
endforeach(instantiation)
|
||||
|
||||
set_source_files_properties(${_instantiations_list}
|
||||
PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON
|
||||
# Force unity builds here
|
||||
set_source_files_properties(${_instantiations_list} PROPERTIES
|
||||
SKIP_UNITY_BUILD_INCLUSION OFF
|
||||
UNITY_BUILD_CANDIDATE ON
|
||||
)
|
||||
set(${instantiations_list} ${_instantiations_list} PARENT_SCOPE)
|
||||
endfunction(vtkm_add_instantiations)
|
||||
|
@ -24,6 +24,14 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(VTKm_CMAKE_MODULE_PATH ${VTKm_SOURCE_DIR}/CMake)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
|
||||
|
||||
# While disabled system-wide, VTK-m uses UNITY builds in some modules
|
||||
set(CMAKE_UNITY_BUILD OFF)
|
||||
|
||||
# By default effectively disable unity builds
|
||||
if (NOT DEFINED CMAKE_UNITY_BUILD_BATCH_SIZE)
|
||||
set(CMAKE_UNITY_BUILD_BATCH_SIZE 1)
|
||||
endif()
|
||||
|
||||
# Determine VTK-m version
|
||||
include(Utilities/Git/Git.cmake)
|
||||
include(VTKmDetermineVersion)
|
||||
|
12
docs/changelog/EnableUnityBuild.md
Normal file
12
docs/changelog/EnableUnityBuild.md
Normal file
@ -0,0 +1,12 @@
|
||||
## Enable Unity build ##
|
||||
|
||||
VTK-m now partially supports unity builds in a subset its sources files which
|
||||
are known to take the longer time/memory to build. Particularly, this enables
|
||||
you to speedup compilation in VTK-m not memory intensive builds (HIP, CUDA) in a
|
||||
system with sufficient resources.
|
||||
|
||||
We use `BATCH` unity builds type and the number of source files per batch can be
|
||||
controlled by the canonical _CMake_ variable: `CMAKE_UNITY_BUILD_BATCH_SIZE`.
|
||||
|
||||
Unity builds requires _CMake_ >= 3.16, if using a older version, unity build
|
||||
will be disabled a regular build will be performed.
|
@ -234,8 +234,6 @@ set(gradient_sources_device
|
||||
vtkm_pyexpander_generated_file(ClipWithFieldExternInstantiations.h)
|
||||
vtkm_pyexpander_generated_file(ClipWithImplicitFunctionExternInstantiations.h)
|
||||
|
||||
set_source_files_properties(Contour.cxx ExtractStructured.cxx PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
|
||||
add_library(vtkm_filter INTERFACE)
|
||||
|
||||
vtkm_library(
|
||||
@ -270,12 +268,14 @@ vtkm_library(
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
|
||||
set_property(TARGET
|
||||
set_target_properties(
|
||||
vtkm_filter_common
|
||||
vtkm_filter_extra
|
||||
vtkm_filter_contour
|
||||
vtkm_filter_gradient
|
||||
PROPERTY UNITY_BUILD_MODE GROUP
|
||||
PROPERTIES
|
||||
UNITY_BUILD ON
|
||||
UNITY_BUILD_MODE BATCH
|
||||
)
|
||||
|
||||
target_link_libraries(vtkm_filter_common PUBLIC vtkm_worklet)
|
||||
|
Loading…
Reference in New Issue
Block a user