# hipcc: CXX\_FILESYSTEM\_CPPFS\_NEEDED test fails - how to add std=c++17

**URL:** https://discourse.cmake.org/t/hipcc-cxx-filesystem-cppfs-needed-test-fails-how-to-add-std-c-17/7897
**Category:** Usage
**Created:** [April 12, 2023, 9:50pm UTC](https://discourse.cmake.org/t/hipcc-cxx-filesystem-cppfs-needed-test-fails-how-to-add-std-c-17/7897 "2023-04-12T21:50:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![eugenewalker](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/e9a140/32.png) [@eugenewalker](https://discourse.cmake.org/u/eugenewalker)
#### Post date: [April 12, 2023, 9:50pm UTC](https://discourse.cmake.org/t/hipcc-cxx-filesystem-cppfs-needed-test-fails-how-to-add-std-c-17/7897/1 "2023-04-12T21:50:04Z")

</div>

I’m trying to build a code that sets `CMAKE_CXX_COMPILER=hipcc`. The system I am on has GCC 11.2.0 and ROCm 5.4.3 (installed to the standard /opt/rocm). CMake version is 3.25.2.

The problem is, cmake check is failing, reporting:

```auto
     43 -- Exawind information:
     44 -- CMAKE_SYSTEM_NAME = Linux
     45 -- CMAKE_CXX_COMPILER_ID = Clang
     46 -- CMAKE_CXX_COMPILER_VERSION = 15.0.0
     47 -- CMAKE_BUILD_TYPE = Release
     48 -- Configuring done
  >> 49 CMake Error at app/exawind/CMakeLists.txt:12 (target_link_libraries):
     50 Target "exawind" links to:
     51
     52 std::filesystem
     53
     54 but the target was not found. Possible reasons include:
     55

```

CMakeError.log shows:

```auto
Performing C++ SOURCE FILE Test CXX_FILESYSTEM_CPPFS_NEEDED failed with the following output:
Change Dir: /tmp/root/spack-stage/spack-stage-exawind-master-ir5j6xzgqsczevsnbqtjmrkme6tkm52k/spack-build-ir5j6xz/CMakeFiles/CMakeScratch/TryCompile-A1e1Bh

Run Build Command(s):/usr/bin/make -f Makefile cmTC_906e3/fast && /usr/bin/make -f CMakeFiles/cmTC_906e3.dir/build.make CMakeFiles/cmTC_906e3.dir/build
make[1]: Entering directory '/tmp/root/spack-stage/spack-stage-exawind-master-ir5j6xzgqsczevsnbqtjmrkme6tkm52k/spack-build-ir5j6xz/CMakeFiles/CMakeScratch/TryCompile-A1e1Bh'
Building CXX object CMakeFiles/cmTC_906e3.dir/src.cxx.o
/opt/rocm-5.4.3/bin/hipcc -DCXX_FILESYSTEM_CPPFS_NEEDED -DUSE_STK_SIMD_NONE -MD -MT CMakeFiles/cmTC_906e3.dir/src.cxx.o -MF CMakeFiles/cmTC_906e3.dir/src.cxx.o.d -o CMakeFiles/cmTC_906e3.dir/src.cxx.o -c /tmp/root/spack-stage/spack-stage-exawind-master-ir5j6xzgqsczevsnbqtjmrkme6tkm52k/spack-build-ir5j6xz/CMakeFiles/CMakeScratch/TryCompile-A1e1Bh/src.cxx
/tmp/root/spack-stage/spack-stage-exawind-master-ir5j6xzgqsczevsnbqtjmrkme6tkm52k/spack-build-ir5j6xz/CMakeFiles/CMakeScratch/TryCompile-A1e1Bh/src.cxx:4:29: error: no member named 'filesystem' in namespace 'std'
            auto cwd = std::filesystem::current_path();
                       ~~~~~ ^
1 error generated when compiling for gfx90a.
make[1]: *** [CMakeFiles/cmTC_906e3.dir/build.make:79: CMakeFiles/cmTC_906e3.dir/src.cxx.o] Error 1
make[1]: Leaving directory '/tmp/root/spack-stage/spack-stage-exawind-master-ir5j6xzgqsczevsnbqtjmrkme6tkm52k/spack-build-ir5j6xz/CMakeFiles/CMakeScratch/TryCompile-A1e1Bh'
make: *** [Makefile:127: cmTC_906e3/fast] Error 2

Source file was:
        #include <filesystem>

        int main() {
            auto cwd = std::filesystem::current_path();
            return static_cast<int>(cwd.string().size());
        }

```

The failing compilation succeeds if I manually add `-std=c++17` and try again on the source file.

I’ve tried setting `CMAKE_HIP_FLAGS=-std=c++17` as well as `HIP_STANDARD=17` and neither got me past this error. Is something funky or is this expected? Any suggestions how I can fix this?

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [April 21, 2023, 9:35pm UTC](https://discourse.cmake.org/t/hipcc-cxx-filesystem-cppfs-needed-test-fails-how-to-add-std-c-17/7897/2 "2023-04-21T21:35:07Z")

</div>

I don’t know if it helps, but AFAIK HIP was added to CMake as a separate language.  
So it should be `CMAKE_HIP_COMPILER` and you need to enable it like `project(MyTest LANGUAGES HIP)`
