diff --git a/nc_cxx.cmake b/nc_cxx.cmake index f91b481..6549cd7 100644 --- a/nc_cxx.cmake +++ b/nc_cxx.cmake @@ -42,22 +42,22 @@ append_compile_flag ("-stdlib=libc++") # 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 - ${NC_CMAKE_BASE}/nc_cxx_stdcxxfs.cpp - LINK_LIBRARIES - ${lib}) + message (STATUS "Trying c++fs library '${lib}'") + try_compile( + __nc_cxx_stdcxxfs ${CMAKE_CURRENT_BINARY_DIR} + SOURCES + ${NC_CMAKE_BASE}/nc_cxx_stdcxxfs.cpp + LINK_LIBRARIES + ${lib} + ) - if (__nc_cxx_stdcxxfs) - set (__nc_cxx_stdcxxfs "${lib}" CACHE INTERNAL "library required for c++ filesystem") - endif () + if (__nc_cxx_stdcxxfs) + set (__nc_cxx_stdcxxfs "${lib}" CACHE INTERNAL "library required for c++ filesystem") + break () endif () endforeach() - if (NOT __nc_cxx_stdcxxfs) + if (NOT DEFINED __nc_cxx_stdcxxfs) message (FATAL_ERROR "Could not locate the required c++fs library") endif ()