From e16ca645ef2ef9a736d1e965053c2cf337c11e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Mon, 17 Apr 2017 15:40:06 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@397 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- CMakeLists.txt | 66 ++++++++++++++++++++++++++++++++----------- src/core/piincludes.h | 7 +++-- src/math/pifft.h | 6 ++-- src/math/pifft_p.h | 6 ++-- 4 files changed, 63 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3468192d..045535e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ file(WRITE "src/pip_version_str.h" "// This file was generated by PIP CMake, don option(ICU "Unicode support" 1) option(USB "USB support" 0) option(STL "Building with STL containers" 0) +option(STL_IOSTREAM "Building with std iostream operators support" 0) option(CRYPT "Crypt support" 0) option(FFTW "fftw3 support for PIFFT" 0) option(FFTW_THREADS "fftw3 support for threadsave" 1) @@ -41,11 +42,22 @@ option(INTROSPECTION_CONTAINERS "Build with containers introspection" 0) option(INTROSPECTION_THREADS "Build with threads introspection" 0) option(LIB "System install" 1) option(DEBUG "Build with -g3" 0) -set(CMAKE_BUILD_TYPE "Release") -set(LIBS) + + if(DEBUG) add_definitions(-DPIP_DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") + message(STATUS "Build debug version") +else() + set(CMAKE_BUILD_TYPE "Release") + message(STATUS "Build relaese version") +endif() + +if(STL_IOSTREAM) + add_definitions(-DPIP_STD_IOSTREAM) + message(STATUS "Building with std iostream operators support") +else() + message(STATUS "Building without std iostream operators support") endif() # Sources @@ -90,6 +102,7 @@ if(PIP_MATH_YN) add_definitions(-DPIP_MATH_YN) endif() +set(LIBS) if(WIN32) list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB}) endif() @@ -151,21 +164,42 @@ endif() # Check if PIP support fftw3 for PIFFT using in math module if(FFTW) - message(STATUS "Building with fftw3 support") -# find_library(${fftw3} ${LIB_}) add_definitions(-DPIP_FFTW) + set(FFTW_LIB_NAME fftw3) + list(APPEND FFTW_LIB_LIST_ ${FFTW_LIB_NAME} ${FFTW_LIB_NAME}f ${FFTW_LIB_NAME}l ${FFTW_LIB_NAME}q) if(WIN32) - add_definitions(-DPIP_FFTW_THREADSAFE) - list(APPEND LIBS fftw3-3 fftw3f-3 fftw3l-3) + foreach(FFTW_LIB_ ${FFTW_LIB_LIST_}) + list(APPEND FFTW_LIB_LIST "${FFTW_LIB_}-3") + endforeach() else() - list(APPEND LIBS fftw3 fftw3f) - if(FFTW_THREADS) - add_definitions(-DPIP_FFTW_THREADSAFE) - list(APPEND LIBS fftw3_threads fftw3f_threads) - else() - message(STATUS "WARNING PIFFTW::preparePlan was not threadsafe") - endif() + set(FFTW_LIB_LIST ${FFTW_LIB_LIST_}) endif() + if(FFTW_THREADS) + add_definitions(-DPIP_FFTW_THREADSAFE) + foreach(FFTW_LIB_T ${FFTW_LIB_LIST}) + list(APPEND FFTW_LIB_LIST "${FFTW_LIB_T}_threads") + endforeach() + else() + message(STATUS "WARNING PIFFTW::preparePlan was not threadsafe") + endif() + foreach(FFTW_LIB ${FFTW_LIB_LIST}) + find_library("${FFTW_LIB}_FOUND" ${FFTW_LIB}) + if(${FFTW_LIB}_FOUND) + message(STATUS "Check ${FFTW_LIB} OK") + list(APPEND LIBS ${FFTW_LIB}) + if("${FFTW_LIB}" MATCHES "${FFTW_LIB_NAME}f") + add_definitions(-DPIP_FFTW_FLOAT) + endif() + if("${FFTW_LIB}" MATCHES "${FFTW_LIB_NAME}l") + add_definitions(-DPIP_FFTW_LDOUBLE) + endif() + if("${FFTW_LIB}" MATCHES "${FFTW_LIB_NAME}q") + add_definitions(-DPIP_FFTW_QDOUBLE) + endif() + else() + message(STATUS "Check ${FFTW_LIB} missing") + endif() + endforeach() else() message(STATUS "Building without fftw3 support") endif() @@ -206,11 +240,11 @@ endif() foreach(LIB_ ${LIBS}) find_library("${LIB_}_FOUND" ${LIB_}) message(STATUS "Check the ${LIB_} is installed: " ${${LIB_}_FOUND}) - if("${${LIB_}_FOUND}" STREQUAL "${LIB_}_FOUND-NOTFOUND") - message(WARNING "library ${LIB_} not found, please install it") - else() + if(${LIB_}_FOUND) list(APPEND LIBS ${LIB_}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIB_}) + else() + message(WARNING "library ${LIB_} not found, please install it") endif() endforeach() if(WIN32) diff --git a/src/core/piincludes.h b/src/core/piincludes.h index f6720329..1aeba224 100755 --- a/src/core/piincludes.h +++ b/src/core/piincludes.h @@ -23,8 +23,11 @@ #include "pibase.h" #include "piflags.h" #include "pimonitor.h" -#include - +#ifdef PIP_STD_IOSTREAM +# include +#else +# include +#endif extern PIMonitor piMonitor; diff --git a/src/math/pifft.h b/src/math/pifft.h index 87b3a420..f3e7abec 100644 --- a/src/math/pifft.h +++ b/src/math/pifft.h @@ -161,6 +161,7 @@ private: }; +#ifdef PIP_FFTW_FLOAT template<> inline const PIVector > & PIFFTW::calcFFT(const PIVector > & in) {return ((_PIFFTW_P_float_*)p)->calcFFT(in);} template<> inline const PIVector > & PIFFTW::calcFFT(const PIVector & in) {return ((_PIFFTW_P_float_*)p)->calcFFTR(in);} template<> inline const PIVector > & PIFFTW::calcFFTinverse(const PIVector > & in) {return ((_PIFFTW_P_float_*)p)->calcFFTI(in);} @@ -169,6 +170,7 @@ template<> inline void PIFFTW::newP(void *& _p) {_p = new _PIFFTW_P_float template<> inline void PIFFTW::deleteP(void *& _p) {if (_p) delete (_PIFFTW_P_float_*)_p; _p = 0;} typedef PIFFTW PIFFTWf; +#endif // PIP_FFTW_FLOAT template<> inline const PIVector > & PIFFTW::calcFFT(const PIVector > & in) {return ((_PIFFTW_P_double_*)p)->calcFFT(in);} @@ -181,7 +183,7 @@ template<> inline void PIFFTW::deleteP(void *& _p) {if (_p) delete (_PIF typedef PIFFTW PIFFTWd; -#ifdef WINDOWS +#ifdef PIP_FFTW_LDOUBLE template<> inline const PIVector > & PIFFTW::calcFFT(const PIVector > & in) {return ((_PIFFTW_P_ldouble_*)p)->calcFFT(in);} template<> inline const PIVector > & PIFFTW::calcFFT(const PIVector & in) {return ((_PIFFTW_P_ldouble_*)p)->calcFFTR(in);} template<> inline const PIVector > & PIFFTW::calcFFTinverse(const PIVector > & in) {return ((_PIFFTW_P_ldouble_*)p)->calcFFTI(in);} @@ -190,6 +192,6 @@ template<> inline void PIFFTW::newP(void *& _p) {_p = new _PIFFTW_P_ldo template<> inline void PIFFTW::deleteP(void *& _p) {if (_p) delete (_PIFFTW_P_ldouble_*)_p; _p = 0;} typedef PIFFTW PIFFTWld; -#endif // WINDOWS +#endif // PIP_FFTW_LDOUBLE #endif // PIFFT_H diff --git a/src/math/pifft_p.h b/src/math/pifft_p.h index 65e1562a..b2fd636d 100644 --- a/src/math/pifft_p.h +++ b/src/math/pifft_p.h @@ -136,6 +136,7 @@ public: #ifdef PIP_FFTW +#ifdef PIP_FFTW_FLOAT template<> inline void PIFFTW_Private::p_createPlan_c2c_1d(void *& plan, int size, const void * in, void * out, int dir, int flags) { plan = fftwf_plan_dft_1d(size, (fftwf_complex *)in, (fftwf_complex *)out, dir, flags);} template<> inline void PIFFTW_Private::p_createPlan_r2c_1d(void *& plan, int size, const void * in, void * out, int flags) { @@ -147,6 +148,7 @@ template<> inline void PIFFTW_Private::p_destroyPlan(void *& plan) {if (p #ifdef PIP_FFTW_THREADSAFE template<> inline void PIFFTW_Private::p_makeThreadSafe() {fftwf_make_planner_thread_safe();} #endif +#endif // PIP_FFTW_FLOAT template<> inline void PIFFTW_Private::p_createPlan_c2c_1d(void *& plan, int size, const void * in, void * out, int dir, int flags) { plan = fftw_plan_dft_1d(size, (fftw_complex *)in, (fftw_complex *)out, dir, flags);} @@ -160,7 +162,7 @@ template<> inline void PIFFTW_Private::p_destroyPlan(void *& plan) {if ( template<> inline void PIFFTW_Private::p_makeThreadSafe() {fftw_make_planner_thread_safe();} #endif -#ifdef WINDOWS +#ifdef PIP_FFTW_LDOUBLE template<> inline void PIFFTW_Private::p_createPlan_c2c_1d(void *& plan, int size, const void * in, void * out, int dir, int flags) { plan = fftwl_plan_dft_1d(size, (fftwl_complex *)in, (fftwl_complex *)out, dir, flags);} template<> inline void PIFFTW_Private::p_createPlan_r2c_1d(void *& plan, int size, const void * in, void * out, int flags) { @@ -172,7 +174,7 @@ template<> inline void PIFFTW_Private::p_destroyPlan(void *& plan) {if #ifdef PIP_FFTW_THREADSAFE template<> inline void PIFFTW_Private::p_makeThreadSafe() {fftwl_make_planner_thread_safe();} #endif -#endif // WINDOWS +#endif // PIP_FFTW_LDOUBLE #endif // PIP_FFTW