ROCMClang ignores target_compile_features for CXX targets
Hi,
I am compiling mixed C CXX and Fortran projects and use hipcc
(ROCMClang 4.1.0) with CMake 3.21.0 as CXX compiler.
For CXX targets, it looks like this ignores target_compile_features
.
Reproducer
CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(test C CXX)
add_executable(main main.cxx)
set_target_properties(main PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(main PUBLIC cxx_std_17)
main.cxx
#include <iostream>
int main() {
std::cout << __cplusplus << std::endl;
}
Build
$ export CC=$(which clang)
$ export CXX=$(which hipcc)
$ cmake -S . -B build
-- The C compiler identification is Clang 12.0.0
-- The CXX compiler identification is ROCMClang 4.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /sw/spock/spack-envs/views/rocm-4.1.0/llvm/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: /sw/spock/spack-envs/views/rocm-4.1.0/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
--- Detecting CXX compile features - done
-- Configuring done
--- Generating done
-- Build files have been written to: /ccs/home/huebl/src/test_cxxstd/build
$ cmake --build build -- VERBOSE=ON
...
Scanning dependencies of target main
...
[ 50%] Building CXX object CMakeFiles/main.dir/main.cxx.o
/sw/spock/spack-envs/views/rocm-4.1.0/llvm/bin/clang++ -o CMakeFiles/main.dir/main.cxx.o -c /ccs/home/huebl/src/test_cxxstd/main.cxx
...
$ cmake --version
cmake version 3.21.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Execute
$ ./build/main
201402
clang++
directly
Using AMD's For comparison, building with AMD's clang++
as CXX directly properly adds -std=c++17
:
$ export CXX=$(which clang++)