File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ include(cmake/introspection.cmake)
101
101
include (cmake/crc32c.cmake )
102
102
include (cmake/leveldb.cmake )
103
103
104
+ include (CheckStdFilesystem )
105
+ check_std_filesystem ()
106
+
104
107
add_subdirectory (src )
105
108
106
109
message ("\n " )
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2023 The Bitcoin Core developers
2
+ # Distributed under the MIT software license, see the accompanying
3
+ # file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ # GCC 8.x (libstdc++) requires -lstdc++fs
6
+ # Clang 8.x (libc++) requires -lc++fs
7
+
8
+ function (check_std_filesystem )
9
+ set (source "
10
+ #include <filesystem>
11
+
12
+ int main()
13
+ {
14
+ (void)std::filesystem::current_path().root_name();
15
+ }
16
+ " )
17
+
18
+ include (CheckCXXSourceCompiles )
19
+ check_cxx_source_links ("${source} " STD_FILESYSTEM_NO_EXTRA_LIBS_NEEDED )
20
+ if (STD_FILESYSTEM_NO_EXTRA_LIBS_NEEDED )
21
+ return ()
22
+ endif ()
23
+
24
+ add_library (std_filesystem INTERFACE )
25
+ check_cxx_source_links_with_libs (stdc++fs "${source} " STD_FILESYSTEM_NEEDS_LINK_TO_LIBSTDCXXFS )
26
+ if (STD_FILESYSTEM_NEEDS_LINK_TO_LIBSTDCXXFS )
27
+ target_link_libraries (std_filesystem INTERFACE stdc++fs )
28
+ return ()
29
+ endif ()
30
+ check_cxx_source_links_with_libs (c++fs "${source} " STD_FILESYSTEM_NEEDS_LINK_TO_LIBCXXFS )
31
+ if (STD_FILESYSTEM_NEEDS_LINK_TO_LIBCXXFS )
32
+ target_link_libraries (std_filesystem INTERFACE c++fs )
33
+ return ()
34
+ endif ()
35
+ message (FATAL_ERROR "Cannot figure out how to use std::filesystem." )
36
+ endfunction ()
You can’t perform that action at this time.
0 commit comments