Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace mpark.variant with std::variant #2851

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
[submodule "externalpackages/git-archive-all.sh"]
path = externalpackages/git-archive-all.sh
url = https://github.com/meitar/git-archive-all.sh/
[submodule "mpark.variant"]
path = externalpackages/mpark.variant
url = https://github.com/mpark/variant.git
[submodule "externalpackages/fmt"]
path = externalpackages/fmt
url = https://github.com/fmtlib/fmt.git
Expand Down
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,7 @@ string(REPLACE
"${CMAKE_BINARY_DIR}/lib" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
CONFIG_LDFLAGS "${CONFIG_LDFLAGS}")
set(BOUT_LIB_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
# Update mpark.variant and fmt include paths if we're building them
if (NOT BOUT_USE_SYSTEM_MPARK_VARIANT)
set(MPARK_VARIANT_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
# Update fmt include paths if we're building it
if (NOT BOUT_USE_SYSTEM_FMT)
set(FMT_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
Expand Down
1 change: 0 additions & 1 deletion bin/bout-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

BOUT_LIB_PATH=@BOUT_LIB_PATH@
BOUT_INCLUDE_PATH=@BOUT_INCLUDE_PATH@
MPARK_VARIANT_INCLUDE_PATH=@MPARK_VARIANT_INCLUDE_PATH@
FMT_INCLUDE_PATH=@FMT_INCLUDE_PATH@
BOUT_CONFIG_FILE=@PREFIX@/make.config

Expand Down
11 changes: 0 additions & 11 deletions bout++Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ if(NOT "@ISINSTALLED@")
if(EXISTS "@CMAKE_BINARY_DIR@/externalpackages/fmt")
list(APPEND CMAKE_PREFIX_PATH "@CMAKE_BINARY_DIR@/externalpackages/fmt")
endif()
if(EXISTS "@CMAKE_BINARY_DIR@/externalpackages/mpark.variant")
list(APPEND CMAKE_PREFIX_PATH "@CMAKE_BINARY_DIR@/externalpackages/mpark.variant")
endif()
if(EXISTS "@CMAKE_BINARY_DIR@/externalpackages/PVODE")
list(APPEND CMAKE_PREFIX_PATH "@CMAKE_BINARY_DIR@/externalpackages/PVODE")
endif()
Expand Down Expand Up @@ -104,13 +101,6 @@ if(EXISTS "@Libuuid_ROOT@")
set(Libuuid_ROOT "@Libuuid_ROOT@")
endif()

if(@BOUT_USE_SYSTEM_MPARK_VARIANT@)
set(mpark_variant_ROOT "@mpark_variant_ROOT@")
else()
# mpark.variant doesn't use GNUInstallDirs, always installs to lib
set(mpark_variant_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../../lib/cmake/mpark_variant")
endif()

if(@BOUT_USE_SYSTEM_FMT@)
set(fmt_ROOT "@fmt_ROOT@")
endif()
Expand Down Expand Up @@ -147,7 +137,6 @@ if (BOUT_HAS_GETTEXT)
find_dependency(Gettext @Gettext_VERSION@)
find_dependency(Intl @Intl_VERSION@)
endif()
find_dependency(mpark_variant @mpark_variant_VERSION@)
find_dependency(fmt @fmt_VERSION@)
if (BOUT_HAS_SLEPC)
find_dependency(SLEPc @SLEPC_VERSION@)
Expand Down
20 changes: 0 additions & 20 deletions cmake/SetupBOUTThirdParty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,6 @@ endif()
message(STATUS "PETSc support: ${BOUT_USE_PETSC}")
set(BOUT_HAS_PETSC ${BOUT_USE_PETSC})


cmake_dependent_option(BOUT_USE_SYSTEM_MPARK_VARIANT "Use external installation of mpark.variant" OFF
"BOUT_UPDATE_GIT_SUBMODULE OR EXISTS ${PROJECT_SOURCE_DIR}/externalpackages/mpark.variant/CMakeLists.txt" ON)

if(BOUT_USE_SYSTEM_MPARK_VARIANT)
message(STATUS "Using external mpark.variant")
find_package(mpark_variant REQUIRED)
get_target_property(MPARK_VARIANT_INCLUDE_PATH mpark_variant INTERFACE_INCLUDE_DIRECTORIES)
else()
message(STATUS "Using mpark.variant submodule")
bout_update_submodules()
add_subdirectory(externalpackages/mpark.variant)
if(NOT TARGET mpark_variant)
message(FATAL_ERROR "mpark_variant not found! Have you disabled the git submodules (BOUT_UPDATE_GIT_SUBMODULE)?")
endif()
set(MPARK_VARIANT_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externalpackages/mpark.variant/include")
set(CONFIG_CFLAGS "${CONFIG_CFLAGS} -I\${MPARK_VARIANT_INCLUDE_PATH}")
endif()
target_link_libraries(bout++ PUBLIC mpark_variant)

cmake_dependent_option(BOUT_USE_SYSTEM_FMT "Use external installation of fmt" OFF
"BOUT_UPDATE_GIT_SUBMODULE OR EXISTS ${PROJECT_SOURCE_DIR}/externalpackages/fmt/CMakeLists.txt" ON)

Expand Down
1 change: 0 additions & 1 deletion externalpackages/mpark.variant
Submodule mpark.variant deleted from 23cb94
30 changes: 6 additions & 24 deletions include/bout/sys/variant.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
#ifndef __VARIANT_HXX__
#define __VARIANT_HXX__

// std::variant added in C++17
//#include <variant>

#include "mpark/variant.hpp"
#include <variant>

#include "bout/utils.hxx"

Expand All @@ -30,16 +27,10 @@ namespace utils {

/// Import variant, visit into bout::utils namespace

// From C++17
// using std::variant;
// using std::visit;
// using std::holds_alternative;
// using std::get;

using mpark::get;
using mpark::holds_alternative;
using mpark::variant;
using mpark::visit;
using std::get;
using std::holds_alternative;
using std::variant;
using std::visit;

////////////////////////////////////////////////////////////
// Variant comparison
Expand Down Expand Up @@ -73,15 +64,6 @@ struct IsEqual {
}
};

/// Backport of std::disjunction
template <class...>
struct disjunction : std::false_type {};
template <class B1>
struct disjunction<B1> : B1 {};
template <class B1, class... Bn>
struct disjunction<B1, Bn...>
: std::conditional_t<bool(B1::value), B1, disjunction<Bn...>> {};

} // namespace details

template <typename T, typename VARIANT_T>
Expand All @@ -90,7 +72,7 @@ struct isVariantMember;
/// Is type `T` a member of variant `variant<ALL_T>`?
template <typename T, typename... ALL_T>
struct isVariantMember<T, variant<ALL_T...>>
: public details::disjunction<std::is_same<T, ALL_T>...> {};
: public std::disjunction<std::is_same<T, ALL_T>...> {};

/// Return true only if the given variant \p v
/// has the same type and value as \p t
Expand Down
4 changes: 0 additions & 4 deletions manual/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ def __getattr__(cls, name):
pydir = "/".join(python.split("/")[:-2])
os.system("which clang-format")
os.system("which clang-format-6.0")
os.system(
"git submodule update --init --recursive ../../externalpackages/mpark.variant"
)
pwd = "/".join(os.getcwd().split("/")[:-2])
os.system("git submodule update --init --recursive ../../externalpackages/fmt")
cmake = (
Expand All @@ -89,7 +86,6 @@ def __getattr__(cls, name):
+ " -DBOUT_TESTS=OFF"
+ " -DBOUT_ALLOW_INSOURCE_BUILD=ON"
+ f" -DPython_ROOT_DIR={pydir}"
+ f" -Dmpark_variant_DIR={pwd}/externalpackages/mpark.variant/"
+ f" -Dfmt_DIR={pwd}/externalpackages/fmt/"
)
# os.system("mkdir ../../build")
Expand Down
20 changes: 0 additions & 20 deletions manual/sphinx/user_docs/advanced_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -698,26 +698,6 @@ to

typedef long CVODEINT;

Compiling with IBM xlC compiler fails
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When using the ``xlC`` compiler, an error may occur::

variant.hpp(1568) parameter pack "Ts" was referenced but not expanded


The workaround is to change line 428 of ``externalpackages/mpark.variant/include/mpark/lib.hpp`` from::

#ifdef MPARK_TYPE_PACK_ELEMENT

to::

#ifdef CAUSES_ERROR // MPARK_TYPE_PACK_ELEMENT

This will force an alternate implementation of type_pack_element to be defined.
See also https://software.intel.com/en-us/forums/intel-c-compiler/topic/501502


Compiling fails after changing branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
18 changes: 8 additions & 10 deletions manual/sphinx/user_docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -380,16 +380,14 @@ to read and write this high-performance parallel file format.
Bundled Dependencies
~~~~~~~~~~~~~~~~~~~~

BOUT++ bundles some dependencies, currently `mpark.variant
<https://github.com/mpark/variant>`_, `fmt <https://fmt.dev>`_ and
`googletest <https://github.com/google/googletest>`_. If you wish to
use an existing installation of ``mpark.variant``, you can set
``-DBOUT_USE_SYSTEM_MPARK_VARIANT=ON``, and supply the installation
path using ``mpark_variant_ROOT`` via the command line or environment
variable if it is installed in a non standard loction. Similarly for
``fmt``, using ``-DBOUT_USE_SYSTEM_FMT=ON`` and ``fmt_ROOT``
respectively. To turn off both, you can set
``-DBOUT_USE_GIT_SUBMODULE=OFF``.
BOUT++ bundles some dependencies, currently `fmt <https://fmt.dev>`_
and `googletest <https://github.com/google/googletest>`_. If you wish
to use an existing installation of ``fmt``, you can set
``-DBOUT_USE_SYSTEM_FMT=ON``, and supply the installation path using
``fmt_ROOT`` via the command line or environment variable if it is
installed in a non standard location. It's also possible to turn off
all bundled dependencies with ``-DBOUT_USE_GIT_SUBMODULE=OFF``
(currently this just affects ``fmt``).

The recommended way to use ``googletest`` is to compile it at the same
time as your project, therefore there is no option to use an external
Expand Down
2 changes: 1 addition & 1 deletion tests/MMS/diffusion2/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build_and_log("MMS diffusion test")
inputs = [
("X", ["mesh:nx"]),
("Y", ["mesh:ny"]),
("Z", ["MZ"]) # ,
("Z", ["MZ"]), # ,
# ("XYZ", ["mesh:nx", "mesh:ny", "MZ"])
]

Expand Down
4 changes: 3 additions & 1 deletion tools/pylib/_boutpp_build/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def build_sdist(sdist_directory, config_settings=None):
print(config_settings, sdist_directory)
enable_gz = True
enable_xz = False
external = {"fmt", "mpark.variant"}
external = {
"fmt",
}
if config_settings is not None:
global useLocalVersion, pkgname
for k, v in config_settings.items():
Expand Down
3 changes: 0 additions & 3 deletions tools/pylib/boutconfig/__init__.py.cin
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ for k, v in config.items():
v.replace(
"${BOUT_INCLUDE_PATH}", "@BOUT_INCLUDE_PATH@"
)
.replace(
"${MPARK_VARIANT_INCLUDE_PATH}", "@MPARK_VARIANT_INCLUDE_PATH@"
)
.replace(
"${FMT_INCLUDE_PATH}", "@FMT_INCLUDE_PATH@"
)
Expand Down
1 change: 0 additions & 1 deletion tools/pylib/boutconfig/__init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ _yesno = {'"yes"': True, '"no"': False, "yes": True, "no": False}
_vars = dict(
BOUT_LIB_PATH="@BOUT_LIB_PATH@",
BOUT_INCLUDE_PATH="@BOUT_INCLUDE_PATH@",
MPARK_VARIANT_INCLUDE_PATH="@MPARK_VARIANT_INCLUDE_PATH@",
FMT_INCLUDE_PATH="@FMT_INCLUDE_PATH@",
BOUT_CONFIG_FILE="@PREFIX@/make.config",
)
Expand Down
1 change: 1 addition & 0 deletions tools/tokamak_grids/all/grid2bout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""

from __future__ import print_function

from numpy import max
Expand Down