diff --git a/configure.ac b/configure.ac index 5162ac1106..51589e1761 100644 --- a/configure.ac +++ b/configure.ac @@ -182,16 +182,22 @@ BOOST_REQUIRE([1.46.1]) BOOST_FORMAT BOOST_TOKENIZER +FILESYSTEM_LIBS='' + # Require Boost Filesystem if the C++17-style header is not present if test "$use_boost_filesystem" = "yes" then AC_MSG_NOTICE([Will check for boost.filesystem library since std::filesystem is not available]) BOOST_FILESYSTEM BOOST_SYSTEM + FILESYSTEM_LIBS="$(BOOST_FILESYSTEM_LIBS) $(BOOST_SYSTEM_LIBS)" else AC_MSG_NOTICE([Will use std::filesystem instead of boost.filesystem]) + FILESYSTEM_LIBS="-lstdc++fs" fi +AC_SUBST([FILESYSTEM_LIBS]) + BOOST_TEST # Boost.Python if required diff --git a/libs/os/fs.h b/libs/os/fs.h index 4fe6ba058c..03053651fb 100644 --- a/libs/os/fs.h +++ b/libs/os/fs.h @@ -2,17 +2,31 @@ * \file * Helper header for std::filesystem feature set. Includes the relevant headers * and defines the common "fs" namespace alias. - * If the compiler library supports the C++17 feature std::filesystem, it will - * include the corresponding headers. All other compilers will refer to the - * headers provided by boost::filesystem. + * If the compiler library supports the C++17 feature std::filesystem, it includes + * the corresponding headers, or fall back to std::experimental::filesystem::v1. + * All other compilers will refer to the headers provided by boost::filesystem. */ #pragma once -// At the time of writing C++17 is still in draft state, but compilers +// We need the HAVE_* symbols created by the configure script +#ifdef HAVE_CONFIG_H +#include +#endif + +// If C++17 is available, use that one +#ifdef HAVE_STD_FILESYSTEM + +#include +namespace fs = std::filesystem; +#define DR_USE_STD_FILESYSTEM + +// At the time of writing C++17 is still in draft state, but some compilers // provide the features through the std::experimental namespace. -#if _MSC_VER >= 1900 +// In Linux, the configure script will check for the header and define the +// HAVE_EXPERIMENTAL_FILESYSTEM symbol for us. +#elif _MSC_VER >= 1900 || defined(HAVE_EXPERIMENTAL_FILESYSTEM) -// Visual Studio 2015 onwards supplies the experimental/filesystem header +// Visual Studio 2015+ and GCC 5.3+ supply the experimental/filesystem header #include namespace fs = std::experimental::filesystem::v1; #define DR_USE_STD_FILESYSTEM diff --git a/libs/wxutil/Makefile.am b/libs/wxutil/Makefile.am index 83719e1236..d18d9b7dfe 100644 --- a/libs/wxutil/Makefile.am +++ b/libs/wxutil/Makefile.am @@ -14,8 +14,7 @@ libwxutil_la_LDFLAGS = -release @PACKAGE_VERSION@ \ $(LIBSIGC_LIBS) \ $(WX_LIBS) \ $(GL_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ + $(FILESYSTEM_LIBS) \ $(GLU_LIBS) \ $(FTGL_LIBS) libwxutil_la_LIBADD = $(top_builddir)/libs/xmlutil/libxmlutil.la \ diff --git a/plugins/archivezip/Makefile.am b/plugins/archivezip/Makefile.am index f89f5cc309..89d30d19c4 100644 --- a/plugins/archivezip/Makefile.am +++ b/plugins/archivezip/Makefile.am @@ -3,6 +3,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(LIBSIGC_CFLAGS) modulesdir = $(pkglibdir)/modules modules_LTLIBRARIES = archivezip.la -archivezip_la_LDFLAGS = -module -avoid-version $(Z_LIBS) $(LIBSIGC_LIBS) +archivezip_la_LDFLAGS = -module -avoid-version $(Z_LIBS) $(LIBSIGC_LIBS) $(FILESYSTEM_LIBS) archivezip_la_SOURCES = ZipArchive.cpp pkzip.cpp plugin.cpp zlibstream.cpp diff --git a/plugins/dm.conversation/Makefile.am b/plugins/dm.conversation/Makefile.am index 85b18eff7d..bd2ee0adfc 100644 --- a/plugins/dm.conversation/Makefile.am +++ b/plugins/dm.conversation/Makefile.am @@ -7,7 +7,7 @@ plugins_LTLIBRARIES = dm_conversation.la dm_conversation_la_LIBADD = $(top_builddir)/libs/wxutil/libwxutil.la \ $(top_builddir)/libs/xmlutil/libxmlutil.la dm_conversation_la_LDFLAGS = -module -avoid-version \ - $(WX_LIBS) $(XML_LIBS) $(BOOST_REGEX_LIBS) + $(WX_LIBS) $(XML_LIBS) dm_conversation_la_SOURCES = plugin.cpp \ ConversationKeyExtractor.cpp \ ConversationCommandInfo.cpp \ diff --git a/plugins/dm.editing/Makefile.am b/plugins/dm.editing/Makefile.am index 6cec7bb4b3..189d91e58c 100644 --- a/plugins/dm.editing/Makefile.am +++ b/plugins/dm.editing/Makefile.am @@ -9,9 +9,7 @@ dm_editing_la_LIBADD = $(top_builddir)/libs/wxutil/libwxutil.la \ dm_editing_la_LDFLAGS = -module -avoid-version \ $(WX_LIBS) \ $(XML_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ - $(BOOST_REGEX_LIBS) + $(FILESYSTEM_LIBS) dm_editing_la_SOURCES = plugin.cpp \ AIHeadPropertyEditor.cpp \ AIEditingPanel.cpp \ diff --git a/plugins/dm.gui/Makefile.am b/plugins/dm.gui/Makefile.am index b830b97188..1082690feb 100644 --- a/plugins/dm.gui/Makefile.am +++ b/plugins/dm.gui/Makefile.am @@ -12,8 +12,7 @@ dm_gui_la_LDFLAGS = -module -avoid-version \ $(XML_LIBS) \ $(GLEW_LIBS) \ $(GL_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) + $(FILESYSTEM_LIBS) dm_gui_la_SOURCES = GuiSelector.cpp \ plugin.cpp \ ReadableEditorDialog.cpp \ diff --git a/plugins/dm.objectives/Makefile.am b/plugins/dm.objectives/Makefile.am index 749948423b..c111c87f25 100644 --- a/plugins/dm.objectives/Makefile.am +++ b/plugins/dm.objectives/Makefile.am @@ -7,7 +7,7 @@ plugins_LTLIBRARIES = dm_objectives.la dm_objectives_la_LIBADD = $(top_builddir)/libs/wxutil/libwxutil.la \ $(top_builddir)/libs/xmlutil/libxmlutil.la dm_objectives_la_LDFLAGS = -module -avoid-version \ - $(BOOST_REGEX_LIBS) $(WX_LIBS) $(XML_LIBS) + $(WX_LIBS) $(XML_LIBS) dm_objectives_la_SOURCES = ObjectivesEditor.cpp \ objectives.cpp \ SpecifierType.cpp \ diff --git a/plugins/dm.stimresponse/Makefile.am b/plugins/dm.stimresponse/Makefile.am index cc87230e40..7979774c35 100644 --- a/plugins/dm.stimresponse/Makefile.am +++ b/plugins/dm.stimresponse/Makefile.am @@ -7,7 +7,7 @@ plugins_LTLIBRARIES = dm_stimresponse.la dm_stimresponse_la_LIBADD = $(top_builddir)/libs/xmlutil/libxmlutil.la \ $(top_builddir)/libs/wxutil/libwxutil.la dm_stimresponse_la_LDFLAGS = -module -avoid-version \ - $(BOOST_REGEX_LIBS) $(WX_LIBS) $(XML_LIBS) + $(WX_LIBS) $(XML_LIBS) dm_stimresponse_la_SOURCES = ResponseEditor.cpp \ plugin.cpp \ StimResponse.cpp \ diff --git a/plugins/eventmanager/Makefile.am b/plugins/eventmanager/Makefile.am index b0bce25aa7..a4bd33c1e9 100644 --- a/plugins/eventmanager/Makefile.am +++ b/plugins/eventmanager/Makefile.am @@ -8,7 +8,7 @@ modules_LTLIBRARIES = eventmgr.la eventmgr_la_LIBADD = $(top_builddir)/libs/xmlutil/libxmlutil.la \ $(top_builddir)/libs/wxutil/libwxutil.la eventmgr_la_LDFLAGS = -module -avoid-version \ - $(LIBSIGC_LIBS) $(XML_LIBS) $(WX_LIBS) $(BOOST_REGEX_LIBS) + $(LIBSIGC_LIBS) $(XML_LIBS) $(WX_LIBS) eventmgr_la_SOURCES = Accelerator.cpp \ Statement.cpp \ EventManager.cpp \ diff --git a/plugins/filters/Makefile.am b/plugins/filters/Makefile.am index 1e05b24bac..a18a6040dc 100644 --- a/plugins/filters/Makefile.am +++ b/plugins/filters/Makefile.am @@ -6,6 +6,6 @@ modules_LTLIBRARIES = filters.la filters_la_LIBADD = $(top_builddir)/libs/xmlutil/libxmlutil.la filters_la_LDFLAGS = -module -avoid-version \ - $(BOOST_REGEX_LIBS) $(XML_LIBS) $(LIBSIGC_LIBS) + $(XML_LIBS) $(LIBSIGC_LIBS) filters_la_SOURCES = XMLFilter.cpp BasicFilterSystem.cpp filters.cpp diff --git a/plugins/fonts/Makefile.am b/plugins/fonts/Makefile.am index 2ea17c4e7f..922794fab4 100644 --- a/plugins/fonts/Makefile.am +++ b/plugins/fonts/Makefile.am @@ -10,9 +10,7 @@ fonts_la_LDFLAGS = -module -avoid-version \ $(XML_LIBS) \ $(GL_LIBS) \ $(GLU_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ - $(BOOST_REGEX_LIBS) \ + $(FILESYSTEM_LIBS) \ $(LIBSIGC_LIBS) fonts_la_SOURCES = plugin.cpp \ FontLoader.cpp \ diff --git a/plugins/mapdoom3/Makefile.am b/plugins/mapdoom3/Makefile.am index 277962835b..6e472d9469 100644 --- a/plugins/mapdoom3/Makefile.am +++ b/plugins/mapdoom3/Makefile.am @@ -11,8 +11,7 @@ mapdoom3_la_LIBADD = $(top_builddir)/libs/wxutil/libwxutil.la \ mapdoom3_la_LDFLAGS = -module -avoid-version \ $(WX_LIBS) \ $(XML_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ + $(FILESYSTEM_LIBS) \ $(GLEW_LIBS) \ $(GL_LIBS) mapdoom3_la_SOURCES = Doom3MapFormat.cpp \ diff --git a/plugins/particles/Makefile.am b/plugins/particles/Makefile.am index ee596a597b..35e0fe00ae 100644 --- a/plugins/particles/Makefile.am +++ b/plugins/particles/Makefile.am @@ -7,9 +7,7 @@ particles_la_LDFLAGS = -module -avoid-version \ -lpthread \ $(GL_LIBS) \ $(WX_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ - $(BOOST_REGEX_LIBS) \ - $(BOOST_SYSTEM_LIBS) + $(FILESYSTEM_LIBS) particles_la_LIBADD = $(top_builddir)/libs/math/libmath.la \ $(top_builddir)/libs/scene/libscenegraph.la \ $(top_builddir)/libs/wxutil/libwxutil.la diff --git a/plugins/script/Makefile.am b/plugins/script/Makefile.am index 3f4f8f0c75..01b0740c7d 100644 --- a/plugins/script/Makefile.am +++ b/plugins/script/Makefile.am @@ -14,8 +14,7 @@ modulesdir = $(pkglibdir)/modules modules_LTLIBRARIES = script.la script_la_LDFLAGS = -module -avoid-version \ - $(BOOST_SYSTEM_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ + $(FILESYSTEM_LIBS) \ $(PYTHON_LIBS) \ $(WX_LIBS) script_la_LIBADD = $(top_builddir)/libs/math/libmath.la \ diff --git a/plugins/uimanager/Makefile.am b/plugins/uimanager/Makefile.am index 80144dd081..41b482a47f 100644 --- a/plugins/uimanager/Makefile.am +++ b/plugins/uimanager/Makefile.am @@ -7,8 +7,7 @@ modules_LTLIBRARIES = uimanager.la uimanager_la_LDFLAGS = -module -avoid-version \ $(WX_LIBS) \ $(XML_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ + $(FILESYSTEM_LIBS) \ $(GLEW_LIBS) \ $(GL_LIBS) uimanager_la_LIBADD = $(top_builddir)/libs/wxutil/libwxutil.la \ diff --git a/plugins/vfspk3/Makefile.am b/plugins/vfspk3/Makefile.am index 39b20939b8..f1c9b16a05 100644 --- a/plugins/vfspk3/Makefile.am +++ b/plugins/vfspk3/Makefile.am @@ -7,8 +7,7 @@ modules_LTLIBRARIES = vfspk3.la vfspk3_la_LDFLAGS = -module -avoid-version \ $(GLIB_LIBS) \ $(XML_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ + $(FILESYSTEM_LIBS) \ $(LIBSIGC_LIBS) vfspk3_la_SOURCES = vfspk3.cpp Doom3FileSystem.cpp DirectoryArchive.cpp diff --git a/plugins/xmlregistry/Makefile.am b/plugins/xmlregistry/Makefile.am index 7da2f2cddc..383297b72f 100644 --- a/plugins/xmlregistry/Makefile.am +++ b/plugins/xmlregistry/Makefile.am @@ -9,8 +9,7 @@ xmlregistry_la_LIBADD = $(top_builddir)/libs/xmlutil/libxmlutil.la xmlregistry_la_LDFLAGS = -module -avoid-version \ $(XML_LIBS) \ $(WX_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ + $(FILESYSTEM_LIBS) \ $(LIBSIGC_LIBS) xmlregistry_la_SOURCES = RegistryTree.cpp XMLRegistry.cpp XMLRegistryModule.cpp diff --git a/radiant/Makefile.am b/radiant/Makefile.am index e5eb88e150..c44d00cbb7 100644 --- a/radiant/Makefile.am +++ b/radiant/Makefile.am @@ -16,9 +16,7 @@ darkradiant_LDFLAGS = $(XML_LIBS) \ $(GLU_LIBS) \ $(FTGL_LIBS) \ $(LIBSIGC_LIBS) \ - $(BOOST_FILESYSTEM_LIBS) \ - $(BOOST_SYSTEM_LIBS) \ - $(BOOST_REGEX_LIBS) \ + $(FILESYSTEM_LIBS) \ $(DL_LIBS) \ $(INTL_LIBS) \ $(WX_LIBS)