From e46716472a8bd30cc3b21f90a1f4b204dac341e1 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 6 May 2019 13:02:15 +1000 Subject: [PATCH] Revert "cxx: remove test for the filesystem library" This reverts commit 874bbb2413ac9cd54c03d6e358623e669042264f. --- nc_cxx.cmake | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/nc_cxx.cmake b/nc_cxx.cmake index 1b782a3..b41d1a7 100644 --- a/nc_cxx.cmake +++ b/nc_cxx.cmake @@ -33,6 +33,39 @@ append_compile_flag ("/std:c++latest") # libstdc++ headers don't behave well under c++17/clang. append_compile_flag ("-stdlib=libc++") +############################################################################### +# find the gcc or clang filesystem library and append to libs if needed +# +# note, we specifically _cannot_ use find_library because it just makes wild +# hardcoded guess and doesn't respect _all_ the system paths; specifically +# something like /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libstdc++.so won't get +# discovered. +if (NOT DEFINED __nc_cxx_stdcxxfs) + foreach(lib "" "c++fs" "c++experimental" "stdc++fs") + if (NOT __nc_cxx_stdcxxfs) + message (STATUS "Trying c++fs library '${lib}'") + try_compile( + __nc_cxx_stdcxxfs ${CMAKE_CURRENT_BINARY_DIR} + SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/nc_cxx_stdcxxfs.cpp + LINK_LIBRARIES + ${lib}) + + if (__nc_cxx_stdcxxfs) + set (__nc_cxx_stdcxxfs "${lib}" CACHE INTERNAL "library required for c++ filesystem") + endif () + endif () + endforeach() + + if (NOT __nc_cxx_stdcxxfs) + message (FATAL_ERROR "Could not locate the required c++fs library") + endif () + + message (STATUS "Using c++fs library ${__nc_cxx_stdcxxfs}") +endif () + +set(NC_CXX_STDCXXFS ${__nc_cxx_stdcxxfs}) + ############################################################################### test_restrict(RESTRICT_KEYWORD)