bump to C++14 standard
This commit is contained in:
+14
-22
@@ -29,22 +29,18 @@
|
||||
## NOTE: More details: https://arma.sourceforge.net/faq.html
|
||||
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
if(NOT (${CMAKE_MAJOR_VERSION} LESS 3))
|
||||
if(POLICY CMP0025)
|
||||
# enable differentiation between vanilla Clang and AppleClang
|
||||
cmake_policy(SET CMP0025 NEW)
|
||||
message(STATUS "*** set cmake policy CMP0025 to NEW")
|
||||
endif()
|
||||
if(POLICY CMP0025)
|
||||
# enable differentiation between vanilla Clang and AppleClang
|
||||
cmake_policy(SET CMP0025 NEW)
|
||||
message(STATUS "*** set cmake policy CMP0025 to NEW")
|
||||
endif()
|
||||
|
||||
if(NOT (CMAKE_VERSION VERSION_LESS "3.1"))
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
message(STATUS "CMAKE_CXX_STANDARD = ${CMAKE_CXX_STANDARD}")
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
message(STATUS "CMAKE_CXX_STANDARD = ${CMAKE_CXX_STANDARD}")
|
||||
|
||||
if(WIN32)
|
||||
message(STATUS "")
|
||||
@@ -92,7 +88,7 @@ if(NOT CXX_FLAGS_EMPTY)
|
||||
endif()
|
||||
|
||||
|
||||
# NOTE: Armadillo requires compiler support for thread_local and C++11
|
||||
# NOTE: Armadillo requires compiler support for thread_local and C++14
|
||||
# NOTE: for Linux, this is available with gcc 4.8.3 onwards
|
||||
# NOTE: for macOS, thread_local is supoported in Xcode 8 (mid 2016 onwards) in C++11 mode
|
||||
|
||||
@@ -101,17 +97,13 @@ endif()
|
||||
|
||||
if(DEFINED CMAKE_CXX_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_VERSION)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
if(NOT (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.8.3))
|
||||
message(STATUS "Detected gcc 4.8.3 or newer")
|
||||
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 6.1.0)
|
||||
message(STATUS "*** WARNING: support for gcc versions older than 6.1 is deprecated")
|
||||
endif()
|
||||
if(NOT (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 6.1.0))
|
||||
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
message(STATUS "Added '-std=c++11' to compiler flags")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
message(STATUS "Added '-std=c++14' to compiler flags")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Compiler too old")
|
||||
message(FATAL_ERROR "Compiler too old; need at least gcc 6.1")
|
||||
endif()
|
||||
else()
|
||||
if(NOT (${CMAKE_MAJOR_VERSION} LESS 3))
|
||||
|
||||
@@ -115,7 +115,7 @@ On macOS, the Accelerate framework can be used for BLAS and LAPACK functions.
|
||||
|
||||
If sparse matrices are not needed, ARPACK and SuperLU are not required.
|
||||
|
||||
Armadillo requires a C++ compiler that supports at least the C++11 standard.
|
||||
Armadillo requires a C++ compiler that supports at least the C++14 standard.
|
||||
|
||||
On Linux-based systems, install the GCC C++ compiler, which is available as a pre-built package.
|
||||
The package name might be `g++` or `gcc-c++` depending on your system.
|
||||
@@ -230,12 +230,12 @@ and hence you will need to link your programs directly with OpenBLAS, LAPACK, et
|
||||
If you have installed Armadillo via the cmake installer,
|
||||
use the following command to compile your programs:
|
||||
|
||||
g++ prog.cpp -o prog -O2 -std=c++11 -larmadillo
|
||||
g++ prog.cpp -o prog -O2 -std=c++14 -larmadillo
|
||||
|
||||
If you have installed Armadillo manually, link with OpenBLAS and LAPACK
|
||||
instead of the Armadillo runtime library:
|
||||
|
||||
g++ prog.cpp -o prog -O2 -std=c++11 -lopenblas -llapack
|
||||
g++ prog.cpp -o prog -O2 -std=c++14 -lopenblas -llapack
|
||||
|
||||
If you have manually installed Armadillo in a non-standard location,
|
||||
such as `/home/user/include/`, you will need to make sure
|
||||
@@ -243,12 +243,12 @@ that your C++ compiler searches `/home/user/include/`
|
||||
by explicitly specifying the directory as an argument/option.
|
||||
For example, using the `-I` switch in GCC and Clang:
|
||||
|
||||
g++ prog.cpp -o prog -O2 -std=c++11 -I /home/user/include/ -lopenblas -llapack
|
||||
g++ prog.cpp -o prog -O2 -std=c++14 -I /home/user/include/ -lopenblas -llapack
|
||||
|
||||
If you're getting linking issues (unresolved symbols),
|
||||
enable the `ARMA_DONT_USE_WRAPPER` option:
|
||||
|
||||
g++ prog.cpp -o prog -O2 -std=c++11 -I /home/user/include/ -DARMA_DONT_USE_WRAPPER -lopenblas -llapack
|
||||
g++ prog.cpp -o prog -O2 -std=c++14 -I /home/user/include/ -DARMA_DONT_USE_WRAPPER -lopenblas -llapack
|
||||
|
||||
If you don't have OpenBLAS, on Linux change `-lopenblas` to `-lblas`;
|
||||
on macOS change `-lopenblas -llapack` to `-framework Accelerate`
|
||||
|
||||
+2
-2
@@ -4,10 +4,10 @@ How to compile example1.cpp
|
||||
** Linux and macOS **
|
||||
|
||||
If you have installed Armadillo via the CMake installer:
|
||||
g++ example1.cpp -o example1 -std=c++11 -O2 -larmadillo
|
||||
g++ example1.cpp -o example1 -std=c++14 -O2 -larmadillo
|
||||
|
||||
Otherwise, if you want to use Armadillo without installation:
|
||||
g++ example1.cpp -o example1 -std=c++11 -O2 -I /home/user/armadillo-12.2.0/include -DARMA_DONT_USE_WRAPPER -lopenblas
|
||||
g++ example1.cpp -o example1 -std=c++14 -O2 -I /home/user/armadillo-12.2.0/include -DARMA_DONT_USE_WRAPPER -lopenblas
|
||||
|
||||
The above command assumes that the armadillo archive was unpacked into /home/user/
|
||||
The command needs to be adjusted if the archive was unpacked into a different directory,
|
||||
|
||||
@@ -16,16 +16,11 @@
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
#undef ARMA_HAVE_CXX11
|
||||
#undef ARMA_HAVE_CXX14
|
||||
#undef ARMA_HAVE_CXX17
|
||||
#undef ARMA_HAVE_CXX20
|
||||
#undef ARMA_HAVE_CXX23
|
||||
|
||||
#if (__cplusplus >= 201103L)
|
||||
#define ARMA_HAVE_CXX11
|
||||
#endif
|
||||
|
||||
#if (__cplusplus >= 201402L)
|
||||
#define ARMA_HAVE_CXX14
|
||||
#endif
|
||||
@@ -47,9 +42,6 @@
|
||||
#if defined(_MSVC_LANG)
|
||||
|
||||
#if (_MSVC_LANG >= 201402L)
|
||||
#undef ARMA_HAVE_CXX11
|
||||
#define ARMA_HAVE_CXX11
|
||||
|
||||
#undef ARMA_HAVE_CXX14
|
||||
#define ARMA_HAVE_CXX14
|
||||
#endif
|
||||
@@ -78,8 +70,8 @@
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(ARMA_HAVE_CXX11)
|
||||
#error "*** C++11 compiler required; enable C++11 mode in your compiler, or use an earlier version of Armadillo"
|
||||
#if !defined(ARMA_HAVE_CXX14)
|
||||
#error "*** C++14 compiler required; enable C++14 mode in your compiler, or use an earlier version of Armadillo"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
#define arma_aligned
|
||||
#define arma_align_mem
|
||||
#define arma_warn_unused
|
||||
#define arma_deprecated
|
||||
#define arma_frown(msg)
|
||||
#define arma_deprecated [[deprecated]]
|
||||
#define arma_frown(msg) [[deprecated(msg)]]
|
||||
#define arma_malloc
|
||||
#define arma_inline inline
|
||||
#define arma_noinline
|
||||
@@ -161,13 +161,12 @@
|
||||
#undef ARMA_GCC_VERSION
|
||||
#define ARMA_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if (ARMA_GCC_VERSION < 40803)
|
||||
#error "*** newer compiler required; need gcc 4.8.3 or newer ***"
|
||||
#if (ARMA_GCC_VERSION < 60100)
|
||||
#error "*** newer compiler required; need gcc 6.1 or newer ***"
|
||||
#endif
|
||||
|
||||
// #if (ARMA_GCC_VERSION < 60100)
|
||||
// #pragma message ("WARNING: support for gcc versions older than 6.1 is deprecated")
|
||||
// #endif
|
||||
// gcc 6.1 has proper C++14 support and fixes an OpenMP related bug:
|
||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57580
|
||||
|
||||
#define ARMA_GOOD_COMPILER
|
||||
|
||||
@@ -377,23 +376,11 @@
|
||||
|
||||
|
||||
#if defined(__SUNPRO_CC)
|
||||
|
||||
// http://www.oracle.com/technetwork/server-storage/solarisstudio/training/index-jsp-141991.html
|
||||
// http://www.oracle.com/technetwork/server-storage/solarisstudio/documentation/cplusplus-faq-355066.html
|
||||
|
||||
#if (__SUNPRO_CC < 0x5140)
|
||||
#error "*** newer compiler required ***"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(ARMA_HAVE_CXX14)
|
||||
#undef arma_deprecated
|
||||
#define arma_deprecated [[deprecated]]
|
||||
|
||||
#undef arma_frown
|
||||
#define arma_frown(msg) [[deprecated(msg)]]
|
||||
#endif
|
||||
|
||||
|
||||
@@ -430,17 +417,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(ARMA_USE_OPENMP)
|
||||
#if (defined(ARMA_GCC_VERSION) && (ARMA_GCC_VERSION < 50400))
|
||||
// due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57580
|
||||
#undef ARMA_USE_OPENMP
|
||||
#if !defined(ARMA_DONT_PRINT_OPENMP_WARNING)
|
||||
#pragma message ("WARNING: use of OpenMP disabled due to compiler bug in gcc <= 5.3")
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (defined(__FAST_MATH__) || (defined(__FINITE_MATH_ONLY__) && (__FINITE_MATH_ONLY__ > 0)) || defined(_M_FP_FAST))
|
||||
#undef ARMA_FAST_MATH
|
||||
#define ARMA_FAST_MATH
|
||||
@@ -496,16 +472,3 @@
|
||||
// https://sourceware.org/bugzilla/show_bug.cgi?id=19239
|
||||
#undef minor
|
||||
#undef major
|
||||
|
||||
|
||||
// optionally allow disabling of compile-time deprecation messages (not recommended)
|
||||
// NOTE: option 'ARMA_IGNORE_DEPRECATED_MARKER' will be removed
|
||||
// NOTE: disabling deprecation messages is counter-productive
|
||||
|
||||
#if defined(ARMA_IGNORE_DEPRECATED_MARKER) && (!defined(ARMA_DONT_IGNORE_DEPRECATED_MARKER)) && (!defined(ARMA_EXTRA_DEBUG))
|
||||
#undef arma_deprecated
|
||||
#define arma_deprecated
|
||||
|
||||
#undef arma_frown
|
||||
#define arma_frown(msg)
|
||||
#endif
|
||||
|
||||
@@ -579,7 +579,7 @@ arma_assert_same_size(const uword A_n_rows, const uword A_n_cols, const uword B_
|
||||
|
||||
|
||||
|
||||
//! stop if given matrices have different sizes
|
||||
//! stop if given matrices do not have the same size
|
||||
template<typename eT1, typename eT2>
|
||||
arma_hot
|
||||
inline
|
||||
@@ -600,7 +600,7 @@ arma_assert_same_size(const Mat<eT1>& A, const Mat<eT2>& B, const char* x)
|
||||
|
||||
|
||||
|
||||
//! stop if given proxies have different sizes
|
||||
//! stop if given proxies do not have the same size
|
||||
template<typename eT1, typename eT2>
|
||||
arma_hot
|
||||
inline
|
||||
@@ -804,7 +804,7 @@ arma_assert_same_size(const uword A_n_rows, const uword A_n_cols, const uword A_
|
||||
|
||||
|
||||
|
||||
//! stop if given cubes have different sizes
|
||||
//! stop if given cubes do not have the same size
|
||||
template<typename eT1, typename eT2>
|
||||
arma_hot
|
||||
inline
|
||||
@@ -883,7 +883,7 @@ arma_assert_same_size(const subview_cube<eT>& A, const ProxyCube<T1>& B, const c
|
||||
|
||||
|
||||
|
||||
//! stop if given cube proxies have different sizes
|
||||
//! stop if given cube proxies do not have the same size
|
||||
template<typename eT1, typename eT2>
|
||||
arma_hot
|
||||
inline
|
||||
@@ -1401,16 +1401,7 @@ arma_assert_atlas_size(const T1& A, const T2& B)
|
||||
inline
|
||||
arma_first_extra_debug_message()
|
||||
{
|
||||
union
|
||||
{
|
||||
unsigned short a;
|
||||
unsigned char b[sizeof(unsigned short)];
|
||||
} endian_test;
|
||||
|
||||
endian_test.a = 1;
|
||||
|
||||
const bool little_endian = (endian_test.b[0] == 1);
|
||||
const char* nickname = ARMA_VERSION_NAME;
|
||||
const char* nickname = ARMA_VERSION_NAME;
|
||||
|
||||
std::ostream& out = get_cerr_stream();
|
||||
|
||||
@@ -1420,7 +1411,6 @@ arma_assert_atlas_size(const T1& A, const T2& B)
|
||||
<< " (" << nickname << ")\n";
|
||||
|
||||
out << "@ arma_config::wrapper = " << arma_config::wrapper << '\n';
|
||||
out << "@ arma_config::cxx14 = " << arma_config::cxx14 << '\n';
|
||||
out << "@ arma_config::cxx17 = " << arma_config::cxx17 << '\n';
|
||||
out << "@ arma_config::cxx20 = " << arma_config::cxx20 << '\n';
|
||||
out << "@ arma_config::cxx23 = " << arma_config::cxx23 << '\n';
|
||||
@@ -1451,10 +1441,8 @@ arma_assert_atlas_size(const T1& A, const T2& B)
|
||||
out << "@ sizeof(long) = " << sizeof(long) << '\n';
|
||||
out << "@ sizeof(uword) = " << sizeof(uword) << '\n';
|
||||
out << "@ sizeof(blas_int) = " << sizeof(blas_int) << '\n';
|
||||
out << "@ little_endian = " << little_endian << '\n';
|
||||
out << "@ ---" << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static arma_first_extra_debug_message arma_first_extra_debug_message_run;
|
||||
|
||||
+5
-5
@@ -3,11 +3,11 @@ LIB_FLAGS = -larmadillo
|
||||
#LIB_FLAGS = -lblas -llapack
|
||||
#LIB_FLAGS = -lopenblas -llapack
|
||||
|
||||
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -O0
|
||||
CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -Og
|
||||
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -Og -fopenmp
|
||||
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -Og -DARMA_DONT_USE_WRAPPER
|
||||
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -Og -fsanitize=address -fsanitize=leak -fsanitize=undefined -fsanitize=bounds -fsanitize=bounds-strict -g
|
||||
#CXX_FLAGS = -std=c++14 -Wshadow -Wall -pedantic -O0
|
||||
CXX_FLAGS = -std=c++14 -Wshadow -Wall -pedantic -Og
|
||||
#CXX_FLAGS = -std=c++14 -Wshadow -Wall -pedantic -Og -fopenmp
|
||||
#CXX_FLAGS = -std=c++14 -Wshadow -Wall -pedantic -Og -DARMA_DONT_USE_WRAPPER
|
||||
#CXX_FLAGS = -std=c++14 -Wshadow -Wall -pedantic -Og -fsanitize=address -fsanitize=leak -fsanitize=undefined -fsanitize=bounds -fsanitize=bounds-strict -g
|
||||
|
||||
|
||||
OBJECTS = $(patsubst %.cpp,%.o,$(wildcard *.cpp))
|
||||
|
||||
Reference in New Issue
Block a user