Files
test2/source/blender/blenlib/CMakeLists.txt
Aras Pranckevicius facb17b0e3 Cleanup: BLI ENUM_OPERATORS cleanup/robustness
BLI code for enums that are meant to be used as "bit flags" defined
an ENUM_OPERATORS macro in BLI_utildefines.h. This cleans up things
related to said macro:

- Move it out into a separate BLI_enum_flags.hh header, instead of
  "random bag of things" that is the current place,
- Update it to no longer need manual indication of highest individual
  bit value. This originally was added in a31a87f89 (2020 Oct), in
  order to silence some UBSan warnings that were coming
  from GPU related structures (looking at current GPU code, I don't
  think this is happening anymore). However, that caused actual
  user-visible bugs due to incorrectly specified max. enum bit value,
  and today 14% of all usages have incorrect highest individual
  bit value spelled out.
    - I have reviewed all usages of operator ~ and none of them are
      used for directly producing a DNA-serialized value; all the
      usages are for masking out other bits for which the new ~
      behavior that just flips all bits is fine.
- Make the macro define flag_is_set() function to ease check of bits
  that are set in C++ enum class cases; update existing cases to use
  that instead of three other ways that were used.

Pull Request: https://projects.blender.org/blender/blender/pulls/148230
2025-10-17 12:57:50 +02:00

631 lines
14 KiB
CMake

# SPDX-FileCopyrightText: 2006 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
if(HAVE_EXECINFO_H)
add_definitions(-DHAVE_EXECINFO_H)
endif()
set(INC
PUBLIC .
../../../intern/eigen
)
set(INC_SYS
../../../extern/wcwidth
../../../extern/json/include
${ZLIB_INCLUDE_DIRS}
${ZSTD_INCLUDE_DIRS}
)
set(SRC
intern/BLI_assert.cc
intern/BLI_color.cc
intern/BLI_colorspace.cc
intern/BLI_dial_2d.cc
intern/BLI_dynstr.cc
intern/BLI_filelist.cc
intern/BLI_ghash.cc
intern/BLI_ghash_utils.cc
intern/BLI_heap.cc
intern/BLI_heap_simple.cc
intern/BLI_kdopbvh.cc
intern/BLI_linklist.cc
intern/BLI_linklist_lockfree.cc
intern/BLI_memarena.cc
intern/BLI_memblock.cc
intern/BLI_memiter.cc
intern/BLI_mempool.cc
intern/BLI_mmap.cc
intern/BLI_subprocess.cc
intern/BLI_timer.cc
intern/array_store.cc
intern/array_store_rle.cc
intern/array_store_utils.cc
intern/array_utils.cc
intern/array_utils_c.cc
intern/astar.cc
intern/atomic_disjoint_set.cc
intern/bit_bool_conversion.cc
intern/bit_ref.cc
intern/bit_span.cc
intern/bitmap.cc
intern/bitmap_draw_2d.cc
intern/boxpack_2d.cc
intern/cache_mutex.cc
intern/compression.cc
intern/compute_context.cc
intern/convexhull_2d.cc
intern/cpp_type.cc
intern/cpp_types.cc
intern/csv_parse.cc
intern/delaunay_2d.cc
intern/dot_export.cc
intern/easing.cc
intern/endian_switch.cc
intern/expr_pylike_eval.cc
intern/fftw.cc
intern/fileops.cc
intern/fileops_c.cc
intern/filereader_file.cc
intern/filereader_gzip.cc
intern/filereader_memory.cc
intern/filereader_zstd.cc
intern/fnmatch.cc
intern/generic_vector_array.cc
intern/generic_virtual_array.cc
intern/generic_virtual_vector_array.cc
intern/gsqueue.cc
intern/hash_md5.cc
intern/hash_mm2a.cc
intern/hash_mm3.cc
intern/hash_tables.cc
intern/implicit_sharing.cc
intern/index_mask.cc
intern/index_mask_expression.cc
intern/index_range.cc
intern/jitter_2d.cc
intern/kdtree_1d.cc
intern/kdtree_2d.cc
intern/kdtree_3d.cc
intern/kdtree_4d.cc
intern/lasso_2d.cc
intern/lazy_threading.cc
intern/length_parameterize.cc
intern/listbase.cc
intern/math_base.cc
intern/math_base_inline.cc
intern/math_base_safe_inline.cc
intern/math_basis_types.cc
intern/math_bits_inline.cc
intern/math_boolean.cc
intern/math_color.cc
intern/math_color_blend_inline.cc
intern/math_color_inline.cc
intern/math_geom.cc
intern/math_geom_inline.cc
intern/math_half.cc
intern/math_interp.cc
intern/math_matrix.cc
intern/math_matrix_c.cc
intern/math_rotation.cc
intern/math_rotation_c.cc
intern/math_solvers.cc
intern/math_statistics.cc
intern/math_time.cc
intern/math_vec.cc
intern/math_vector.cc
intern/math_vector_inline.cc
intern/memory_cache.cc
intern/memory_cache_file_load.cc
intern/memory_counter.cc
intern/memory_utils.cc
intern/mesh_boolean.cc
intern/mesh_intersect.cc
intern/noise.cc
intern/noise_c.cc
intern/offset_indices.cc
intern/ordered_edge.cc
intern/path_utils.cc
intern/polyfill_2d.cc
intern/polyfill_2d_beautify.cc
intern/quadric.cc
intern/radial_tiling_shared.cc
intern/rand.cc
intern/rct.cc
intern/resource_scope.cc
intern/scanfill.cc
intern/scanfill_utils.cc
intern/serialize.cc
intern/session_uid.cc
intern/smaa_textures.cc
intern/sort.cc
intern/sort_utils.cc
intern/stack.cc
intern/storage.cc
intern/string.cc
intern/string_cursor_utf8.cc
intern/string_ref.cc
intern/string_search.cc
intern/string_utf8.cc
intern/string_utils.cc
intern/system.cc
intern/task_graph.cc
intern/task_iterator.cc
intern/task_pool.cc
intern/task_range.cc
intern/task_scheduler.cc
intern/tempfile.cc
intern/threads.cc
intern/time.cc
intern/timecode.cc
intern/timeit.cc
intern/uuid.cc
intern/vector.cc
intern/virtual_array.cc
intern/voxel.cc
intern/winstuff.cc
intern/winstuff_dir.cc
intern/winstuff_registration.cc
# Private headers.
intern/BLI_mempool_private.h
# Header as source (included in C files above).
intern/kdtree_impl.h
intern/list_sort_impl.h
intern/radial_tiling_shared.hh
BLI_alloca.h
BLI_allocator.hh
BLI_any.hh
BLI_array.hh
BLI_array_state.hh
BLI_array_store.h
BLI_array_store_utils.h
BLI_array_utils.h
BLI_array_utils.hh
BLI_asan.h
BLI_assert.h
BLI_astar.h
BLI_atomic_disjoint_set.hh
BLI_binary_search.hh
BLI_bit_bool_conversion.hh
BLI_bit_group_vector.hh
BLI_bit_ref.hh
BLI_bit_span.hh
BLI_bit_span_ops.hh
BLI_bit_span_to_index_ranges.hh
BLI_bit_vector.hh
BLI_bitmap.h
BLI_bitmap_draw_2d.h
BLI_bounds.hh
BLI_bounds_types.hh
BLI_boxpack_2d.h
BLI_build_config.h
BLI_cache_mutex.hh
BLI_color.hh
BLI_color_mix.hh
BLI_colorspace.hh
BLI_compiler_attrs.h
BLI_compiler_compat.h
BLI_compiler_typecheck.h
BLI_compression.hh
BLI_compute_context.hh
BLI_concurrent_map.hh
BLI_console.h
BLI_convexhull_2d.hh
BLI_cpp_type.hh
BLI_cpp_type_make.hh
BLI_cpp_types.hh
BLI_cpp_types_make.hh
BLI_csv_parse.hh
BLI_delaunay_2d.hh
BLI_devirtualize_parameters.hh
BLI_dial_2d.h
BLI_disjoint_set.hh
BLI_dot_export.hh
BLI_dot_export_attribute_enums.hh
BLI_dynstr.h
BLI_easing.h
BLI_endian_defines.h
BLI_endian_switch.h
BLI_endian_switch_inline.h
BLI_enum_flags.hh
BLI_enumerable_thread_specific.hh
BLI_expr_pylike_eval.h
BLI_fftw.hh
BLI_fileops.h
BLI_fileops.hh
BLI_fileops_types.h
BLI_filereader.h
BLI_fixed_width_int.hh
BLI_fixed_width_int_str.hh
BLI_fnmatch.h
BLI_function_ref.hh
BLI_generic_array.hh
BLI_generic_key.hh
BLI_generic_key_string.hh
BLI_generic_pointer.hh
BLI_generic_span.hh
BLI_generic_value_map.hh
BLI_generic_vector_array.hh
BLI_generic_virtual_array.hh
BLI_generic_virtual_vector_array.hh
BLI_ghash.h
BLI_gsqueue.h
BLI_hash.h
BLI_hash.hh
BLI_hash_fwd.hh
BLI_hash_md5.hh
BLI_hash_mm2a.hh
BLI_hash_mm3.hh
BLI_hash_tables.hh
BLI_heap.h
BLI_heap_simple.h
BLI_implicit_sharing.h
BLI_implicit_sharing.hh
BLI_implicit_sharing_ptr.hh
BLI_index_mask.hh
BLI_index_mask_expression.hh
BLI_index_mask_fwd.hh
BLI_index_range.hh
BLI_index_ranges_builder.hh
BLI_index_ranges_builder_fwd.hh
BLI_inplace_priority_queue.hh
BLI_iterator.h
BLI_jitter_2d.h
BLI_kdopbvh.hh
BLI_kdtree.h
BLI_kdtree_impl.h
BLI_lasso_2d.hh
BLI_lazy_threading.hh
BLI_length_parameterize.hh
BLI_linear_allocator.hh
BLI_linear_allocator_chunked_list.hh
BLI_link_utils.h
BLI_linklist.h
BLI_linklist_lockfree.h
BLI_linklist_stack.h
BLI_listbase.h
BLI_listbase_wrapper.hh
BLI_map.hh
BLI_map_slots.hh
BLI_math_angle_types.hh
BLI_math_axis_angle.hh
BLI_math_axis_angle_types.hh
BLI_math_base.h
BLI_math_base.hh
BLI_math_base_safe.h
BLI_math_basis_types.hh
BLI_math_bits.h
BLI_math_boolean.hh
BLI_math_color.h
BLI_math_color.hh
BLI_math_color_blend.h
BLI_math_constants.h
BLI_math_euler.hh
BLI_math_euler_types.hh
BLI_math_geom.h
BLI_math_half.hh
BLI_math_inline.h
BLI_math_interp.hh
BLI_math_matrix.h
BLI_math_matrix.hh
BLI_math_matrix_types.hh
BLI_math_mpq.hh
BLI_math_numbers.hh
BLI_math_quaternion.hh
BLI_math_quaternion_types.hh
BLI_math_rotation.h
BLI_math_rotation.hh
BLI_math_rotation_legacy.hh
BLI_math_rotation_types.hh
BLI_math_solvers.h
BLI_math_statistics.h
BLI_math_time.h
BLI_math_vector.h
BLI_math_vector.hh
BLI_math_vector_mpq_types.hh
BLI_math_vector_types.hh
BLI_math_vector_unroll.hh
BLI_memarena.h
BLI_memblock.h
BLI_memiter.h
BLI_memory_cache.hh
BLI_memory_cache_file_load.hh
BLI_memory_counter.hh
BLI_memory_counter_fwd.hh
BLI_memory_utils.h
BLI_memory_utils.hh
BLI_mempool.h
BLI_mesh_boolean.hh
BLI_mesh_intersect.hh
BLI_mmap.h
BLI_multi_value_map.hh
BLI_mutex.hh
BLI_noise.h
BLI_noise.hh
BLI_offset_indices.hh
BLI_offset_span.hh
BLI_ordered_edge.hh
BLI_parameter_pack_utils.hh
BLI_path_utils.hh
BLI_polyfill_2d.h
BLI_polyfill_2d_beautify.h
BLI_pool.hh
BLI_probing_strategies.hh
BLI_quadric.h
BLI_radial_tiling.hh
BLI_rand.h
BLI_rand.hh
BLI_random_access_iterator_mixin.hh
BLI_rect.h
BLI_resource_scope.hh
BLI_scanfill.h
BLI_serialize.hh
BLI_session_uid.h
BLI_set.hh
BLI_set_slots.hh
BLI_shared_cache.hh
BLI_simd.hh
BLI_smaa_textures.h
BLI_sort.h
BLI_sort.hh
BLI_sort_utils.h
BLI_span.hh
BLI_stack.h
BLI_stack.hh
BLI_strict_flags.h
BLI_string.h
BLI_string_cursor_utf8.h
BLI_string_ref.hh
BLI_string_search.hh
BLI_string_utf8.h
BLI_string_utf8_symbols.h
BLI_string_utils.hh
BLI_struct_equality_utils.hh
BLI_sub_frame.hh
BLI_subprocess.hh
BLI_sys_types.h
BLI_system.h
BLI_task.h
BLI_task.hh
BLI_task_size_hints.hh
BLI_tempfile.h
BLI_threads.h
BLI_time.h
BLI_time_utildefines.h
BLI_timecode.h
BLI_timeit.hh
BLI_timer.h
BLI_unique_sorted_indices.hh
BLI_unroll.hh
BLI_utildefines.h
BLI_utildefines_iter.h
BLI_utildefines_stack.h
BLI_utildefines_variadic.h
BLI_utility_mixins.hh
BLI_uuid.h
BLI_vector.hh
BLI_vector_list.hh
BLI_vector_set.hh
BLI_vector_set_slots.hh
BLI_virtual_array.hh
BLI_virtual_array_fwd.hh
BLI_virtual_vector_array.hh
BLI_voxel.h
BLI_winstuff.h
BLI_winstuff_com.hh
# Without these files listed, they aren't known to CMake.
../../../extern/json/include/json.hpp
)
set(LIB
PUBLIC bf::dna
PRIVATE bf::extern::fmtlib
PRIVATE bf::extern::xxhash
bf_intern_eigen
PRIVATE bf::intern::guardedalloc
extern_wcwidth
PRIVATE bf::intern::atomic
PRIVATE extern_fmtlib
PUBLIC bf::dependencies::optional::tbb
PRIVATE bf::dependencies::eigen
${ZLIB_LIBRARIES}
${ZSTD_LIBRARIES}
)
if(NOT WITH_PYTHON_MODULE)
list(APPEND SRC
intern/BLI_args.cc
BLI_args.h
)
endif()
if(WITH_MEM_VALGRIND)
add_definitions(-DWITH_MEM_VALGRIND)
endif()
if(WITH_GMP)
add_definitions(-DWITH_GMP)
list(APPEND INC_SYS
${GMP_INCLUDE_DIRS}
)
list(APPEND LIB
${GMP_LIBRARIES}
)
endif()
if(WITH_FFTW3)
list(APPEND INC_SYS
${FFTW3_INCLUDE_DIRS}
)
list(APPEND LIB
${FFTW3_LIBRARIES}
)
add_definitions(-DWITH_FFTW3)
endif()
if(WIN32)
if(WITH_BLENDER_THUMBNAILER)
# Needed for querying the `thumbnailer .dll` in `winstuff.c`.
add_definitions(-DWITH_BLENDER_THUMBNAILER)
endif()
list(APPEND INC
../../../intern/uriconvert
../../../intern/utfconv
)
list(APPEND LIB
bf_intern_uriconvert
bf_intern_utfconv
dxgi
)
list(APPEND SRC
intern/system_win32.cc
)
endif()
if(APPLE)
list(APPEND SRC
intern/fileops_apple.mm
intern/storage_apple.mm
)
endif()
if(UNIX AND NOT APPLE)
list(APPEND LIB
bf_intern_libc_compat
)
endif()
# no need to compile object files for inline headers.
set_source_files_properties(
intern/math_base_inline.cc
intern/math_base_safe_inline.cc
intern/math_bits_inline.cc
intern/math_color_blend_inline.cc
intern/math_color_inline.cc
intern/math_geom_inline.cc
intern/math_vector_inline.cc
PROPERTIES HEADER_FILE_ONLY TRUE
)
blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_library(bf::blenlib ALIAS bf_blenlib)
if(WITH_GTESTS)
set(TEST_SRC
tests/BLI_any_test.cc
tests/BLI_array_state_test.cc
tests/BLI_array_store_test.cc
tests/BLI_array_test.cc
tests/BLI_array_utils_test.cc
tests/BLI_binary_search_test.cc
tests/BLI_bit_group_vector_test.cc
tests/BLI_bit_ref_test.cc
tests/BLI_bit_span_test.cc
tests/BLI_bit_vector_test.cc
tests/BLI_bitmap_test.cc
tests/BLI_bounds_test.cc
tests/BLI_build_config_test.cc
tests/BLI_color_test.cc
tests/BLI_compression_test.cc
tests/BLI_convexhull_2d_test.cc
tests/BLI_cpp_type_test.cc
tests/BLI_csv_parse_test.cc
tests/BLI_delaunay_2d_test.cc
tests/BLI_disjoint_set_test.cc
tests/BLI_expr_pylike_eval_test.cc
tests/BLI_fileops_test.cc
tests/BLI_fixed_width_int_test.cc
tests/BLI_function_ref_test.cc
tests/BLI_generic_array_test.cc
tests/BLI_generic_span_test.cc
tests/BLI_generic_vector_array_test.cc
tests/BLI_ghash_test.cc
tests/BLI_hash_mm2a_test.cc
tests/BLI_heap_simple_test.cc
tests/BLI_heap_test.cc
tests/BLI_implicit_sharing_test.cc
tests/BLI_index_mask_expression_test.cc
tests/BLI_index_mask_test.cc
tests/BLI_index_range_test.cc
tests/BLI_index_ranges_builder_test.cc
tests/BLI_inplace_priority_queue_test.cc
tests/BLI_kdopbvh_test.cc
tests/BLI_kdtree_test.cc
tests/BLI_length_parameterize_test.cc
tests/BLI_linear_allocator_chunked_list_test.cc
tests/BLI_linear_allocator_test.cc
tests/BLI_linklist_lockfree_test.cc
tests/BLI_listbase_test.cc
tests/BLI_map_test.cc
tests/BLI_math_base_safe_test.cc
tests/BLI_math_base_test.cc
tests/BLI_math_bits_test.cc
tests/BLI_math_color_test.cc
tests/BLI_math_geom_test.cc
tests/BLI_math_half_test.cc
tests/BLI_math_interp_test.cc
tests/BLI_math_matrix_test.cc
tests/BLI_math_matrix_types_test.cc
tests/BLI_math_rotation_test.cc
tests/BLI_math_rotation_types_test.cc
tests/BLI_math_solvers_test.cc
tests/BLI_math_time_test.cc
tests/BLI_math_vector_test.cc
tests/BLI_math_vector_types_test.cc
tests/BLI_memiter_test.cc
tests/BLI_memory_cache_test.cc
tests/BLI_memory_counter_test.cc
tests/BLI_memory_utils_test.cc
tests/BLI_mesh_boolean_test.cc
tests/BLI_mesh_intersect_test.cc
tests/BLI_multi_value_map_test.cc
tests/BLI_offset_indices_test.cc
tests/BLI_path_utils_test.cc
tests/BLI_polyfill_2d_test.cc
tests/BLI_pool_test.cc
tests/BLI_random_access_iterator_mixin_test.cc
tests/BLI_ressource_strings.h
tests/BLI_serialize_test.cc
tests/BLI_session_uid_test.cc
tests/BLI_set_test.cc
tests/BLI_span_test.cc
tests/BLI_stack_cxx_test.cc
tests/BLI_stack_test.cc
tests/BLI_string_ref_test.cc
tests/BLI_string_search_test.cc
tests/BLI_string_test.cc
tests/BLI_string_utf8_test.cc
tests/BLI_string_utils_test.cc
tests/BLI_task_graph_test.cc
tests/BLI_task_test.cc
tests/BLI_tempfile_test.cc
tests/BLI_unique_sorted_indices_test.cc
tests/BLI_utildefines_test.cc
tests/BLI_uuid_test.cc
tests/BLI_vector_list_test.cc
tests/BLI_vector_set_test.cc
tests/BLI_vector_test.cc
tests/BLI_virtual_array_test.cc
tests/BLI_exception_safety_test_utils.hh
)
set(TEST_INC
../imbuf
)
set(TEST_LIB
bf_blenlib
)
blender_add_test_suite_executable(BLI "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
add_subdirectory(tests/performance)
endif()