You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CI builds using Ubuntu 18.04 were failing to make it past the CMake
configuration stage due to being unable to find <filesystem> support.
This is because Ubuntu 18.04 ships GCC 7, for which <filesystem> support
was still experimental. As a result, <experimental/filesystem> was
present, not <filesystem>, which causes the CMake check to error out as
the test program #includes <filesystem>.
The fix is simple - use __has_include to include the appropriate header
and add a namespace alias to account for std::experimental.
This is sufficient to get the CMake configuration to succeed using GCC 7
on macOS, but configuration still fails on Ubuntu 18.04 due to the
linker being unable to find the definition for current_path() [0].
This error seems a bit weird since the linker command line clearly
includes -lstdc++fs, and that library definitely defines current_path().
It turns out the Ubuntu 18.04 linker is order-sensitive, and -lstdc++fs
was present on the command line before the object file for the test
program, so the linker doesn't pull in the current_path() definition.
ld64 on macOS, on the other hand, doesn't seem to be sensitive to
library order [1].
Fixing this is fairly simple - use the LINK_LIBRARIES try_compile option
instead of LINK_OPTIONS, so CMake puts the flag in the right place. I
should have done that in the first place, but I somehow glossed over
that option when first writing the new handling.
[0]:
[ 50%] Linking CXX executable cmTC_6f62e
/root/cmake-3.27.8-linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/cmTC_6f62e.dir/link.txt --verbose=1
/usr/bin/c++ -Wall -Wextra -Wpedantic -Werror -lstdc++fs CMakeFiles/cmTC_6f62e.dir/std_fs_support_test.cpp.o -o cmTC_6f62e
CMakeFiles/cmTC_6f62e.dir/std_fs_support_test.cpp.o: In function `main':
std_fs_support_test.cpp:(.text+0x1f): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
collect2: error: ld returned 1 exit status
[1]:
[100%] Linking CXX executable cmTC_fb65e
/usr/local/Cellar/cmake/3.27.7/bin/cmake -E cmake_link_script CMakeFiles/cmTC_fb65e.dir/link.txt --verbose=1
/usr/local/opt/gcc@7/bin/g++-7 -Wall -Wextra -Wpedantic -Werror -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -mmacosx-version-min=10.12 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lstdc++fs CMakeFiles/cmTC_fb65e.dir/std_fs_support_test.cpp.o -o cmTC_fb65e
ld: warning: dylib (/usr/local/Cellar/gcc@7/7.5.0_4/lib/gcc/7/libstdc++.dylib) was built for newer macOS version (10.17.5) than being linked (10.12)
ld: warning: object file (/usr/local/Cellar/gcc@7/7.5.0_4/lib/gcc/7/libstdc++fs.a(dir.o)) was built for newer macOS version (10.17) than being linked (10.12)
ld: warning: object file (/usr/local/Cellar/gcc@7/7.5.0_4/lib/gcc/7/libstdc++fs.a(ops.o)) was built for newer macOS version (10.17) than being linked (10.12)
ld: warning: object file (/usr/local/Cellar/gcc@7/7.5.0_4/lib/gcc/7/libstdc++fs.a(path.o)) was built for newer macOS version (10.17) than being linked (10.12)
ld: warning: object file (/usr/local/Cellar/gcc@7/7.5.0_4/lib/gcc/7/libstdc++fs.a(cow-dir.o)) was built for newer macOS version (10.17) than being linked (10.12)
ld: warning: object file (/usr/local/Cellar/gcc@7/7.5.0_4/lib/gcc/7/libstdc++fs.a(cow-ops.o)) was built for newer macOS version (10.17) than being linked (10.12)
ld: warning: object file (/usr/local/Cellar/gcc@7/7.5.0_4/lib/gcc/7/libstdc++fs.a(cow-path.o)) was built for newer macOS version (10.17) than being linked (10.12)
[100%] Built target cmTC_fb65e
0 commit comments