Skip to content

Commit 479aa71

Browse files
committed
build: deprecate experimental filesystem
1 parent 1b1592f commit 479aa71

File tree

5 files changed

+23
-38
lines changed

5 files changed

+23
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ CMakeSettings.json
2222
gh-md-toc
2323
/.vs
2424
/CMakeSettings.json
25+
.PVS-Studio
2526

2627
# Hidden files
2728
.DS_Store

CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ if (MATPLOTPP_BUILD_INSTALLER)
146146
# Install the file Matplot++Config.cmake
147147
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Matplot++Config.cmake
148148
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Matplot++)
149-
150-
# Install cmake to find filesystem as a dependency
151-
if (NOT MATPLOTPP_BUILD_SHARED_LIBS)
152-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindFilesystem.cmake
153-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Matplot++)
154-
endif ()
155149
endif ()
156150

157151
#######################################################

Matplot++Config.cmake.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ if(NOT ${MATPLOT_BUILT_SHARED})
1515
include(CMakeFindDependencyMacro)
1616
list(APPEND CMAKE_MODULE_PATH ${MATPLOT_CONFIG_INSTALL_DIR})
1717
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
18-
find_dependency(Filesystem COMPONENTS Experimental Final)
1918
# OpenGL backend
2019
if (@MATPLOTPP_BUILD_EXPERIMENTAL_OPENGL_BACKEND@)
2120
find_dependency(glad)

source/matplot/CMakeLists.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
if(NOT MINGW)
2-
find_package(Filesystem REQUIRED COMPONENTS Experimental Final)
3-
endif()
4-
51
#######################################################
62
### Library ###
73
#######################################################
@@ -102,13 +98,7 @@ target_include_directories(matplot
10298
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
10399

104100
# Dependencies
105-
if(TARGET std::filesystem AND NOT MINGW)
106-
target_link_libraries_system(matplot
107-
PRIVATE cimg nodesoup std::filesystem)
108-
else()
109-
target_link_libraries_system(matplot
110-
PRIVATE cimg nodesoup)
111-
endif()
101+
target_link_libraries_system(matplot PRIVATE cimg nodesoup)
112102

113103
# Required compiler features required
114104
# https://cmake.org/cmake/help/v3.14/manual/cmake-compile-features.7.html#requiring-language-standards
@@ -131,12 +121,6 @@ maybe_target_pedantic_warnings(matplot)
131121
#######################################################
132122
### Definitions ###
133123
#######################################################
134-
# Use experimental filesystem if std::filesystem is not available yet
135-
if(NOT MINGW)
136-
if (CXX_FILESYSTEM_IS_EXPERIMENTAL)
137-
target_compile_definitions(matplot PRIVATE CXX_FILESYSTEM_IS_EXPERIMENTAL)
138-
endif()
139-
endif()
140124
# Some hack to not depend on FILE* internals
141125
# https://github.com/alandefreitas/matplotplusplus/issues/4
142126
include(CheckSymbolExists)

source/matplot/backend/gnuplot.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@
33
//
44

55
#include "gnuplot.h"
6-
#ifdef CXX_FILESYSTEM_IS_EXPERIMENTAL
7-
#include <experimental/filesystem>
8-
#else
9-
#include <filesystem>
10-
#endif
6+
117
#include <cstdlib>
128
#include <iostream>
139
#include <matplot/util/common.h>
1410
#include <matplot/util/popen.h>
1511
#include <regex>
1612
#include <thread>
1713

14+
#ifdef __has_include
15+
#if __has_include(<filesystem>)
16+
#include <filesystem>
17+
#else
18+
#define CXX_NO_FILESYSTEM
19+
#endif
20+
#else
21+
#define CXX_NO_FILESYSTEM
22+
#endif
23+
1824
#ifdef MATPLOT_HAS_FBUFSIZE
1925

2026
#include <stdio_ext.h>
@@ -116,14 +122,13 @@ namespace matplot::backend {
116122
}
117123

118124
// look at the extension
119-
#ifdef CXX_FILESYSTEM_IS_EXPERIMENTAL
120-
namespace fs = std::experimental::filesystem;
121-
#else
125+
#ifndef CXX_NO_FILESYSTEM
122126
namespace fs = std::filesystem;
123-
#endif
124-
125127
fs::path p{filename};
126128
std::string ext = p.extension().string();
129+
#else
130+
std::string ext = filename.substr(filename.find_last_of('.'));
131+
#endif
127132

128133
// check terminal for that extension
129134
SV_CONSTEXPR auto exts = extension_terminal();
@@ -169,11 +174,8 @@ namespace matplot::backend {
169174
}
170175

171176
// Create file if it does not exist
172-
#ifdef CXX_FILESYSTEM_IS_EXPERIMENTAL
173-
namespace fs = std::experimental::filesystem;
174-
#else
177+
#ifndef CXX_NO_FILESYSTEM
175178
namespace fs = std::filesystem;
176-
#endif
177179
fs::path p{filename};
178180
if (!p.parent_path().empty() && !fs::exists(p.parent_path())) {
179181
fs::create_directory(p.parent_path());
@@ -183,12 +185,17 @@ namespace matplot::backend {
183185
return false;
184186
}
185187
}
188+
#endif
186189

187190
output_ = filename;
188191
terminal_ = format;
189192

190193
// Append extension if needed
194+
#ifndef CXX_NO_FILESYSTEM
191195
std::string ext = p.extension().string();
196+
#else
197+
std::string ext = filename.substr(filename.find_last_of('.'));
198+
#endif
192199
if (ext.empty()) {
193200
output_ += it->first;
194201
}

0 commit comments

Comments
 (0)