Skip to content

[CMake] "Deducing this" feature check failure on supported compilers when using MP_UNITS_API_NO_CRTP=ON #722

@alex-tee

Description

@alex-tee

I've started using mp-units in my C++23 project. It compiles and runs fine on my local Arch Linux machine with clang20 and on one of my Debian build machines using GCC, but I get wrong CMake configuration errors that my MSVC/AppleClang versions on my other build machines apparently don't support deducing this. I'm pretty sure they do because my project already uses deducing this and it has been compiling and running as expected on those machines with those compilers. I started getting the following CMake errors since adding mp-units:

MSVC 19.44.35213.0

-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.45.2.windows.1")
-- The C compiler identification is MSVC 19.44.35213.0
-- The CXX compiler identification is MSVC 19.44.35213.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Project version: 2.0.0 (v2.0.0-DEV)
-- Found PkgConfig: C:/ProgramData/chocolatey/bin/pkg-config.exe (found version "0.28")
...
-- CPM: Adding package [email protected] (8489cc2299a58cdf603f2521f982359959d907ea to C:/CPM-cache/mp-units/b278)
-- MP_UNITS_BUILD_AS_SYSTEM_HEADERS: ON
-- MP_UNITS_BUILD_CXX_MODULES: OFF
-- Checking C++ feature test macro '__cpp_lib_format'
-- Checking C++ feature test macro '__cpp_lib_format' - SUCCESS
-- Checking C++ feature test macro '__cpp_explicit_this_parameter'
-- Checking C++ feature test macro '__cpp_explicit_this_parameter' - FAIL
-- Checking C++ feature test macro '__cpp_constexpr_exceptions >= 202411L'
-- Checking C++ feature test macro '__cpp_constexpr_exceptions >= 202411L' - FAIL
-- MP_UNITS_API_STD_FORMAT: ON
-- MP_UNITS_API_NO_CRTP: ON
-- MP_UNITS_API_THROWING_CONSTRAINTS: OFF
-- MP_UNITS_API_FREESTANDING: OFF
-- MP_UNITS_API_CONTRACTS: NONE
-- MP_UNITS_API_NATURAL_UNITS: OFF
CMake Error at C:/CPM-cache/mp-units/b278/src/CMakeLists.txt:109 (message):
  `NO_CRTP` mode enabled but explicit `this` parameter is not supported
-- Configuring incomplete, errors occurred!

AppleClang 17.0.0.17000319

-- Using SDK: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
-- Found Git: /usr/bin/git (found version "2.50.1 (Apple Git-155)")
-- The C compiler identification is AppleClang 17.0.0.17000319
-- The CXX compiler identification is AppleClang 17.0.0.17000319
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The OBJC compiler identification is AppleClang 17.0.0.17000319
-- Detecting OBJC compiler ABI info
-- Detecting OBJC compiler ABI info - done
-- Check for working OBJC compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
-- The OBJCXX compiler identification is AppleClang 17.0.0.17000319
-- Detecting OBJCXX compiler ABI info
-- Detecting OBJCXX compiler ABI info - done
-- Check for working OBJCXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Project version: 2.0.0 (v2.0.0-DEV)
-- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "2.4.3")
...
-- CPM: Adding package [email protected] (8489cc2299a58cdf603f2521f982359959d907ea to /Users/alex/.cache/CPM/mp-units/b278)
-- Checking if libc++ is being used
--   Looking for _LIBCPP_VERSION
--   Looking for _LIBCPP_VERSION - found
-- Checking if libc++ is being used - found
-- MP_UNITS_BUILD_AS_SYSTEM_HEADERS: ON
-- MP_UNITS_BUILD_CXX_MODULES: OFF
-- Checking C++ feature test macro '__cpp_lib_format'
-- Checking C++ feature test macro '__cpp_lib_format' - FAIL
-- Checking C++ feature test macro '__cpp_explicit_this_parameter'
-- Checking C++ feature test macro '__cpp_explicit_this_parameter' - FAIL
-- Checking C++ feature test macro '__cpp_constexpr_exceptions >= 202411L'
-- Checking C++ feature test macro '__cpp_constexpr_exceptions >= 202411L' - FAIL
-- AppleClang 16+ with libc++ detected, overriding `std::format` support
-- MP_UNITS_API_STD_FORMAT: ON
-- MP_UNITS_API_NO_CRTP: ON
-- MP_UNITS_API_THROWING_CONSTRAINTS: OFF
-- MP_UNITS_API_FREESTANDING: OFF
-- MP_UNITS_API_CONTRACTS: NONE
-- MP_UNITS_API_NATURAL_UNITS: OFF
CMake Error at /Users/alex/.cache/CPM/mp-units/b278/src/CMakeLists.txt:109 (message):
  `NO_CRTP` mode enabled but explicit `this` parameter is not supported
-- Configuring incomplete, errors occurred!

Looking at https://cppstat.dev/ and https://en.cppreference.com/w/cpp/compiler_support/23 (at least for MSVC) it looks like these compilers should support deducing this.

Note that configuration succeeds if I omit passing MP_UNITS_API_NO_CRTP (presumably because it fallbacks to CRTP automatically).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions