Skip to content

Fix CMake options being forced in the cache - #268

Merged
zfergus merged 1 commit into
mainfrom
fix/cmake-cache-force
Oct 12, 2026
Merged

zfergus merged 1 commit into
mainfrom
fix/cmake-cache-force

Conversation

@zfergus

@zfergus zfergus commented Oct 12, 2026

Copy link
Copy Markdown
Member

Description

Replaces the CACHE ... FORCE overrides in the CMake configuration with option defaults and normal-variable shadowing, touching the option setup, the SIMD and CUDA fallbacks, and the oneTBB recipe.

  • Option defaults: IPC_TOOLKIT_BUILD_TESTS now defaults to ${IPC_TOOLKIT_TOPLEVEL_PROJECT} and IPC_TOOLKIT_BUILD_PYTHON to OFF, replacing the if/else that forced both OFF in the cache.
  • SIMD fallback: shadows IPC_TOOLKIT_WITH_SIMD with a normal variable when find_package(SIMD) fails.
  • CUDA fallback: when IPC_TOOLKIT_WITH_CUDA is on but no CUDA compiler is found, warns and builds without CUDA instead of failing in enable_language(CUDA).
  • oneTBB: sets BUILD_SHARED_LIBS as a normal variable inside onetbb_import_target(), replacing the push_variable/pop_variable macros (−25 lines).

Impact:

  • A user's -DIPC_TOOLKIT_WITH_SIMD=ON is no longer overwritten. The fallback now lasts one configure, rather than keeping the option OFF in the build directory after SIMD becomes available.
  • Projects that embed IPC Toolkit no longer have their cache rewritten.
  • No source or API changes.

Behavior change

  • A parent project can now enable IPC_TOOLKIT_BUILD_TESTS and IPC_TOOLKIT_BUILD_PYTHON when adding IPC Toolkit as a subdirectory. The defaults are unchanged (both OFF).

Why the oneTBB change is more than style

  • The old CACHE PATH ... FORCE changed the type of the BUILD_SHARED_LIBS cache entry from BOOL to PATH.
  • With CMP0126 NEW, it had no effect when the caller already had a normal BUILD_SHARED_LIBS: the child scope kept seeing the caller's value, so TBB_PREFER_STATIC=ON could be ignored. Reproduced with a stub subdirectory.
  • The function's own scope now provides the save/restore, and oneTBB's add_subdirectory inherits the value.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which improves existing functionality)

How Has This Been Tested?

CMake configure checks only. No build or test run; CI covers that.

  • Top-level configure with -DIPC_TOOLKIT_BUILD_TESTS=ON: oneTBB is configured as libtbb.a, and BUILD_SHARED_LIBS is not left in the cache.
  • SIMD fallback, forced with -DSIMD_CXX_FLAGS=: prints the warning, IPC_TOOLKIT_WITH_SIMD stays ON in the cache, and config.hpp leaves it undefined.
  • Subproject build from a parent that sets BUILD_SHARED_LIBS ON (with IPC_TOOLKIT_WITH_ABSEIL=OFF, since Abseil can't build shared on macOS): tbb is a STATIC_LIBRARY, the parent's value is unchanged, and tests and Python default to OFF.
  • Not tested: the CUDA fallback (no CUDA toolchain on this machine) and a parent opting in to tests.

Test Configuration:

  • OS and Version: macOS 26.6.2
  • Compiler and Version: AppleClang 21.0, CMake 4.1.1

Checklist

  • I have followed the project style guide
  • My code follows the clang-format style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

- Default IPC_TOOLKIT_BUILD_TESTS to ON only at the top level instead of
  forcing it and IPC_TOOLKIT_BUILD_PYTHON OFF in a parent's cache
- Shadow IPC_TOOLKIT_WITH_SIMD with a normal variable when SIMD is not found
- Set BUILD_SHARED_LIBS as a function-local variable when building oneTBB
- Fall back to a CPU build when CUDA is requested but no compiler is found

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.92%. Comparing base (61ff288) to head (cfbc46a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #268      +/-   ##
==========================================
- Coverage   96.92%   96.92%   -0.01%     
==========================================
  Files         194      194              
  Lines       17349    17348       -1     
  Branches      943      943              
==========================================
- Hits        16816    16815       -1     
  Misses        533      533              
Flag Coverage Δ
unittests 96.92% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zfergus
zfergus merged commit 3c9be7b into main Oct 12, 2026
15 of 16 checks passed
@zfergus
zfergus deleted the fix/cmake-cache-force branch October 12, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant