Skip to content

fix(cmake): guard test_constexpr for C++17+; remove duplicate add_test#694

Merged
kris-jusiak merged 4 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/cxx14-cmake-constexpr-guard
May 28, 2026
Merged

fix(cmake): guard test_constexpr for C++17+; remove duplicate add_test#694
kris-jusiak merged 4 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/cxx14-cmake-constexpr-guard

Conversation

@PavelGuzenfeld
Copy link
Copy Markdown
Contributor

@PavelGuzenfeld PavelGuzenfeld commented May 27, 2026

Problem

test/ft/constexpr.cpp uses two C++17-only features:

  • Constexpr lambdas
  • static_assert without message

test/ft/CMakeLists.txt registered the target unconditionally, so a
CMake-based C++14 build would attempt to compile it and fail.

Additionally, the file had a duplicate add_test(test_constexpr test_constexpr)
left at line 82 from an earlier refactor, which caused a CMake warning about a
duplicate test name.

Fix

Wrap add_executable(test_constexpr) and add_test(test_constexpr) in:

if(CMAKE_CXX_STANDARD GREATER_EQUAL 17)
  ...
endif()

Remove the duplicate add_test entry.

Related

Testing

  • CMake C++14 build: test_constexpr target absent, all other 34 tests pass.
  • CMake C++17 build: test_constexpr present and passes; total 35 tests pass.
  • CMake C++20 build: 35 tests pass.

Note: the root Makefile still lacks this guard — tracked in #693.

constexpr.cpp uses constexpr lambdas and static_assert without message,
both of which are C++17 features. Skip the target when building with C++14.

Also remove a duplicate add_test(test_constexpr ...) left at line 82 from
an earlier refactor.
@kris-jusiak kris-jusiak merged commit 97df292 into boost-ext:master May 28, 2026
5 checks passed
@PavelGuzenfeld PavelGuzenfeld deleted the fix/cxx14-cmake-constexpr-guard branch May 28, 2026 05:48
kris-jusiak pushed a commit that referenced this pull request May 28, 2026
- test/ft/errors/CMakeLists.txt: enable all four compile-error tests
  (not_callable, not_configurable, not_dispatchable, not_transitional)
  using OBJECT/EXCLUDE_FROM_ALL + WILL_FAIL TRUE pattern; fixes #569

- CMakeLists.txt: merge duplicate if(SML_BUILD_BENCHMARKS) blocks;
  add add_custom_target(style) for clang-format and add_custom_target
  (clang-tidy) for static analysis, both gated on find_program

- example/CMakeLists.txt: normalise test names to example_ prefix
  for actions_guards and arduino so ctest -E/-R filtering is consistent

- Makefile: replace per-file compile rules with a thin cmake/ctest
  wrapper; preserves public interface (make test, make example,
  make all, CXXSTD=, MEMCHECK=, COVERAGE=); build dir is
  build-$(CXXSTD)/ so multiple standards coexist; docs targets dropped
  (mkdocs/Python scripts remain as standalone commands per CONTRIBUTING)

Includes static_assert(true,"") cherry-pick from PR #698; will be
dropped on next rebase after #698 merges.

Fixes #569, closes #693 (Makefile c++14 constexpr guard subsumed by
cmake wrapper which relies on the PR #694 cmake guard).
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.

2 participants