diff --git a/CMakeLists.txt b/CMakeLists.txt index f3fa42e0..74161685 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ include(GetGitRevisionDescription) include(ReplaceIdefixSource) include(AddIdefixSource) include(SetIdefixProperty) +include(SetRequiredBuildSettingsForGCC8) #Idefix requires Cuda Lambdas (experimental) if(Kokkos_ENABLE_CUDA) @@ -50,6 +51,9 @@ add_subdirectory(src/kokkos build/kokkos) # Add Idefix CXX Flags add_compile_options(${Idefix_CXX_FLAGS}) +# Add filesystem libraries for GCC8 +set_required_build_settings_for_GCC8() + if(Idefix_WERROR) if(Kokkos_ENABLE_CUDA) add_compile_options(-Xcudafe --promote_warnings) diff --git a/cmake/SetRequiredBuildSettingsForGCC8.cmake b/cmake/SetRequiredBuildSettingsForGCC8.cmake new file mode 100644 index 00000000..bb389298 --- /dev/null +++ b/cmake/SetRequiredBuildSettingsForGCC8.cmake @@ -0,0 +1,9 @@ +# The std::filesystem functions are part of the C++17 standard, but GCC8 +# does not store them in libstdc++ but in libstdc++-fs. This function +# ensure that we link to this additional library when using GCC8 +# from https://discourse.cmake.org/t/correct-way-to-link-std-filesystem-with-gcc-8/4121 +function( set_required_build_settings_for_GCC8 ) + # Always link with libstdc++fs.a when using GCC 8. + # Note: This command makes sure that this option comes pretty late on the cmdline. + link_libraries( "$<$,$,9.0>>:-lstdc++fs>" ) +endfunction() diff --git a/doc/source/faq.rst b/doc/source/faq.rst index 87de503a..f7d5461a 100644 --- a/doc/source/faq.rst +++ b/doc/source/faq.rst @@ -39,11 +39,6 @@ The compilation stops while compiling Kokkos with ``/usr/include/stdlib.h(58): e When using the Intel compiler on a Mac Intel, I get a linking error involving the ``SharedAllocationRecordIvvE18t_tracking_enabledE`` symbol. This is a known bug of the Intel Mac compiler with Kokkos. Apparently Intel has decided not to fix it. Check the issue on the `Kokkos git page `_. -I get an error at link that says there are undefined symbols fo std::filesystem - This is a known bug/limitation of gcc8 that does not include filesystem extensions in the standard library. - You should try to clear up CMakeCache.txt and explicitely add the required link library when calling cmake as in - ``LDFLAGS=-lstdc++fs cmake $IDEFIX_DIR ...``` - Execution ---------