From e0c6ee3c59c5f33997d31d427b6d783366f277ec Mon Sep 17 00:00:00 2001
From: Michael Kuron <mkuron@icp.uni-stuttgart.de>
Date: Mon, 11 Nov 2019 14:00:55 +0100
Subject: [PATCH] Detect std::variant from CMake

---
 CMakeLists.txt           | 6 ++++++
 cmake/TestStdVariant.cpp | 7 +++++++
 src/core/Variant.h       | 4 ----
 3 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 cmake/TestStdVariant.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a39496e7..f6d4810a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -497,6 +497,12 @@ else()
    endif()
 endif()
 
+try_compile( WALBERLA_USE_STD_VARIANT "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdVariant.cpp"
+             COMPILE_DEFINITIONS -DWALBERLA_USE_STD_VARIANT ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} )
+if( WALBERLA_USE_STD_VARIANT )
+   message( STATUS "Found std::variant")
+endif()
+
 
 
 ############################################################################################################################
diff --git a/cmake/TestStdVariant.cpp b/cmake/TestStdVariant.cpp
new file mode 100644
index 000000000..be98d121f
--- /dev/null
+++ b/cmake/TestStdVariant.cpp
@@ -0,0 +1,7 @@
+#include <iostream>
+#include <variant>
+
+int main() {
+   std::variant<int,float> a;
+   return 0;
+}
diff --git a/src/core/Variant.h b/src/core/Variant.h
index 6e4d580e4..7fe6d195a 100644
--- a/src/core/Variant.h
+++ b/src/core/Variant.h
@@ -22,10 +22,6 @@
 #pragma once
 
 
-#if __cpp_lib_variant
-#define WALBERLA_USE_STD_VARIANT
-#endif
-
 #if defined(WALBERLA_USE_STD_VARIANT)
 #include <variant>
 #else
-- 
GitLab