IntelLLVM: on Windows, does not respect CXX_STANDARD
On Windows with Intel LLVM oneAPI 2021.3 "icx" C++ compiler, CMake 3.20/3.21 doesn't emit the required "/std:c++17" or similar flag.
This does work as expected on MacOS and Linux with "icpx".
So it could be something internal to CMake where "icx" isn't getting the "/std:c++17" like flag.
Reproduce with this CMakeLists.txt. This example is chosen as one that fails on many current compilers without the /std
flag.
cmake_minimum_required(VERSION 3.20)
project(test LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANARD_REQUIRED true)
include(CheckSourceCompiles)
check_source_compiles(CXX
"#include <filesystem>
int main() {
std::filesystem::path p;
return EXIT_SUCCESS;}"
HAVE_CXX_FILESYSTEM
)
The incorrect result here is that HAVE_CXX_FILESYSTEM is false.
if I add set(CMAKE_REQUIRED_FLAGS /std:c++17)
then HAVE_CXX_FILESYSTEM is true as expected. The actual feature or C++ standard (17, 20, etc.) doesn't seem to matter--IntelLLVM on Windows does not add the /std:
flag added from CMake.
This failure is also true for a simple target like:
add_executable(hello hello.cxx)
target_compile_features(hello PRIVATE cxx_std_17)
The Intel classic "icl" on Windows does work as expected.