@@ -15,12 +15,8 @@ macro(setup_compiler)
15
15
16
16
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra" )
17
17
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors" )
18
-
19
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
20
- link_libraries (stdc++fs)
21
- endif ()
18
+
22
19
elseif (CMAKE_CXX_COMPILER_ID MATCHES Intel)
23
- # link_libraries(stdc++fs)
24
20
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.1)
25
21
message (FATAL_ERROR "Intel compiler is too old, besthea can be"
26
22
" compiled only with icpc 19.0.1 or higher" )
@@ -60,6 +56,34 @@ macro(setup_compiler)
60
56
add_compile_definitions (DATA_WIDTH=${DATA_WIDTH} )
61
57
endmacro ()
62
58
59
+ macro (enable_filesystem)
60
+ # try without -lstd++fs
61
+ try_run (RUNS_WITH_STDFS COMPILES_WITH_STDFS
62
+ "${CMAKE_BINARY_DIR} /try"
63
+ "${CMAKE_SOURCE_DIR} /cmake/has_stdfs.cpp"
64
+ CMAKE_FLAGS -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON
65
+ RUN_OUTPUT_VARIABLE TRY_OUTPUT)
66
+
67
+ if (NOT COMPILES_WITH_STDFS OR RUNS_WITH_STDFS STREQUAL "FAILED_TO_RUN" )
68
+ # try with -lstd++fs
69
+ try_run (RUNS_WITH_STDFS COMPILES_WITH_STDFS
70
+ "${CMAKE_BINARY_DIR} /try"
71
+ "${CMAKE_SOURCE_DIR} /cmake/has_stdfs.cpp"
72
+ CMAKE_FLAGS -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON
73
+ LINK_LIBRARIES stdc++fs
74
+ RUN_OUTPUT_VARIABLE TRY_OUTPUT)
75
+
76
+ if (NOT COMPILES_WITH_STDFS OR RUNS_WITH_STDFS STREQUAL "FAILED_TO_RUN" )
77
+ message (FATAL_ERROR "No std::filesystem support" )
78
+ else ()
79
+ message (STATUS "Found std::filesystem: libstdc++fs" )
80
+ link_libraries (stdc++fs)
81
+ endif ()
82
+ else ()
83
+ message (STATUS "Found std::filesystem: libstdc++" )
84
+ endif ()
85
+ endmacro ()
86
+
63
87
# also adds flag to linker, but we want to link against iomp5
64
88
#macro(enable_OpenMP)
65
89
# find_package(OpenMP REQUIRED)
0 commit comments