cmake 3.17.0-3.17.2 won't bootstrap with icpc (Parallel Studio 2020 SP1 on CentOS8.1)

icpc version number is actually

I haven’t tested other parallel studio’s but I had no problems building 3.16.2 with it. The issue appears to be this line that appeared in bootstrap in 3.17.0

#if (__cplusplus >= 201703L || defined(__INTEL_COMPILER) && defined(__cpp_if_constexpr))

error message during bootstrap is this:

error: no instance of function template "get_ptr" matches the argument list
            argument types are: (std::unique_ptr<int, std::default_delete<int>>)
: note: this candidate was rejected because at least one template argument could not be deduced
  typename T::pointer get_ptr(T& item)

compilation aborted for cmake.cxx (code 2)

changing the line to read as follows

#if (!defined(__INTEL_COMPILER) && __cplusplus >= 201703L || defined(__INTEL_COMPILER) && defined(__cpp_deduction_guides) && __cpp_deduction_guides > 201703L)

is working for me. Intel claims that 19.1 supports P0091R3 but in light of the error message I went with a “greater than” instead of a >=. This only matters if CXXFLAGS includes -std=c++17. Compiling with the default standard or even up through c++14 would work fine with >= because _cpp_deduction_guides isn’t even defined on those releases.

Thanks for your investigation.

Is it possible for you to log an issue regarding this problem?

The code in question was added to the bootstrap script by CMake MR 4139 for consistency with normal CMake configure step check added by CMake MR 4064. The defined(__INTEL_COMPILER) && defined(__cpp_if_constexpr) condition is an attempt at determining whether Intel 19+ is in C++17 mode since __cplusplus never seems to go above 201103L.

As of icpc the bootstrap script still works for me and chooses -std=gnu++14. Is this failure new to icpc Why wouldn’t it just fail the C++17 check and fall back to C++14 like in other versions? Is __cpp_if_constexpr defined in pre-17 modes with that version?

The proposed code:

#if (!defined(__INTEL_COMPILER) && __cplusplus >= 201703L \
   || defined(__INTEL_COMPILER) && defined(__cpp_deduction_guides) \
      && __cpp_deduction_guides > 201703L)

looks like it is using __cpp_deduction_guides instead of __cpp_if_constexpr to detect C++17 support. I’d be fine with switching to that but I’d like to understand what goes wrong with the current code first.

Also, is the !defined(__INTEL_COMPILER) part actually needed? AFAIK the Intel compiler never defines __cplusplus >= 201703L, and if it ever does the code being checked should work.

A similar problem was reported in CMake Issue 21013.

We do have nightly testing with every version of the Intel compiler versions 16 through 19.0, and the BootstrapTest passes with all of them.