Skip to content

Replace CMAKE_C_FLAGS with target_compile_options, simplify LTO - #403

Merged
PJK merged 1 commit into
masterfrom
cmake-target-options
Feb 8, 2026
Merged

PJK merged 1 commit into
masterfrom
cmake-target-options

Conversation

@PJK

@PJK PJK commented Feb 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Create cbor_project_options INTERFACE library for project-wide compile options (warnings, optimization, debug flags), linked by tests and examples
  • Set compile options directly on the cbor target (exported targets cannot have PRIVATE INTERFACE library deps in CMake < 3.15)
  • Guard CMAKE_INTERPROCEDURAL_OPTIMIZATION by LTO_SUPPORTED and remove redundant set_property(DIRECTORY ...) blocks — the CMAKE variable already initializes target properties for all subsequently created targets
  • Remove redundant -DNDEBUG from Release flags (CMake adds it automatically)
  • Sanitizer and coverage flags stay in CMAKE_C_FLAGS because they need both compile and link, and target_link_options requires CMake 3.13+

Stacked on #402.

Test plan

  • Clean configure + build with -DWITH_TESTS=ON -DSANITIZE=ON succeeds
  • All 26 tests pass
  • CI passes (Linux GCC, Linux Clang, MSVC, 32-bit, ARM, FreeBSD)

🤖 Generated with Claude Code

@PJK
PJK force-pushed the cmake-target-options branch from 65a2ed1 to 6ada5f6 Compare February 8, 2026 23:49
- Create cbor_project_options INTERFACE library for project-wide compile
  options (warnings, optimization, debug flags) used by tests and examples
- Set compile options directly on the cbor target (exported target cannot
  have PRIVATE INTERFACE library deps in CMake < 3.15)
- Guard CMAKE_INTERPROCEDURAL_OPTIMIZATION by LTO_SUPPORTED and remove
  redundant set_property(DIRECTORY ...) blocks
- Sanitizer/coverage flags stay in CMAKE_C_FLAGS (need compile+link,
  target_link_options requires CMake 3.13)
- Remove redundant -DNDEBUG from Release flags (CMake adds it automatically)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@PJK
PJK force-pushed the cmake-target-options branch from 6ada5f6 to 89eb70b Compare February 8, 2026 23:49
@PJK
PJK merged commit 190a9c1 into master Feb 8, 2026
15 of 16 checks passed
@PJK
PJK deleted the cmake-target-options branch February 8, 2026 23:58
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

⌂ 换网址