From 66147db7a77abcd75970dc4d834d202a98cd356c Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Tue, 24 Jun 2014 17:10:14 +0100 Subject: [PATCH] Check for std::(tr1::)function support --- CMakeLists.txt | 10 ++++++++++ CMakeModules/CheckStdFunctional.cmake | 13 +++++++++++++ CMakeModules/CheckStdTr1Functional.cmake | 13 +++++++++++++ src/libtomahawk/utils/Closure.h | 3 ++- src/tomahawk/Config.h.in | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 CMakeModules/CheckStdFunctional.cmake create mode 100644 CMakeModules/CheckStdTr1Functional.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a353e191..0a759f418 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,6 +221,16 @@ if( BUILD_GUI AND UNIX AND NOT APPLE ) find_package( X11 ) endif() +# Check if we can use or need +include( CheckStdFunctional ) +check_std_functional( CXX_STD_FUNCTIONAL ) +include( CheckStdTr1Functional ) +check_std_tr1_functional( CXX_STD_TR1_FUNCTIONAL ) +if ( NOT CXX_STD_FUNCTIONAL AND NOT CXX_STD_TR1_FUNCTIONAL ) + message( FATAL_ERROR + "Used compiler neither provides std::function nor std::tr1::function") +endif() + macro_optional_find_package(Echonest 2.2.0) macro_log_feature(ECHONEST_FOUND "Echonest" "Qt library for communicating with The Echo Nest" "http://projects.kde.org/libechonest" TRUE "" "libechonest 2.2.0 is needed for dynamic playlists and the infosystem") diff --git a/CMakeModules/CheckStdFunctional.cmake b/CMakeModules/CheckStdFunctional.cmake new file mode 100644 index 000000000..a129a4e41 --- /dev/null +++ b/CMakeModules/CheckStdFunctional.cmake @@ -0,0 +1,13 @@ +# taglib changed filenames to be a char/wchar struct on some platforms, need to check for it +macro (CHECK_STD_FUNCTIONAL CXX_STD_FUNCTIONAL) + include (CheckCXXSourceCompiles) + check_cxx_source_compiles( + " + #include + using std::function; + int main() + { + return 0; + }" ${CXX_STD_FUNCTIONAL}) +endmacro() + diff --git a/CMakeModules/CheckStdTr1Functional.cmake b/CMakeModules/CheckStdTr1Functional.cmake new file mode 100644 index 000000000..0ba41b95a --- /dev/null +++ b/CMakeModules/CheckStdTr1Functional.cmake @@ -0,0 +1,13 @@ +# taglib changed filenames to be a char/wchar struct on some platforms, need to check for it +macro (CHECK_STD_TR1_FUNCTIONAL CXX_STD_TR1_FUNCTIONAL) + include (CheckCXXSourceCompiles) + check_cxx_source_compiles( + " + #include + using std::tr1::function; + int main() + { + return 0; + }" ${CXX_STD_TR1_FUNCTIONAL}) +endmacro() + diff --git a/src/libtomahawk/utils/Closure.h b/src/libtomahawk/utils/Closure.h index 013993ac1..1763d05f1 100644 --- a/src/libtomahawk/utils/Closure.h +++ b/src/libtomahawk/utils/Closure.h @@ -21,9 +21,10 @@ #ifndef CLOSURE_H #define CLOSURE_H +#include "config.h" #include "DllMacro.h" -#ifdef _WEBSOCKETPP_CPP11_STL_ +#if defined(_WEBSOCKETPP_CPP11_STL_) || defined(CXX_STD_FUNCTIONAL) #include using std::function; #else diff --git a/src/tomahawk/Config.h.in b/src/tomahawk/Config.h.in index 94bae07ef..996536ca0 100644 --- a/src/tomahawk/Config.h.in +++ b/src/tomahawk/Config.h.in @@ -11,6 +11,7 @@ #cmakedefine SNOW_LEOPARD #cmakedefine LEOPARD #cmakedefine HAVE_SPARKLE +#cmakedefine CXX_STD_FUNCTIONAL #cmakedefine WITH_CRASHREPORTER #cmakedefine WITH_BINARY_ATTICA