diff --git a/CheckHostBlasReturnComplex.cmake b/CheckHostBlasReturnComplex.cmake index 30063b1cc3..b9528ce45a 100644 --- a/CheckHostBlasReturnComplex.cmake +++ b/CheckHostBlasReturnComplex.cmake @@ -20,8 +20,8 @@ FUNCTION(CHECK_HOST_BLAS_RETURN_COMPLEX VARNAME) #define F77_BLAS_MANGLE${F77_BLAS_MANGLE} extern \"C\" { - std::complex F77_BLAS_MANGLE(zdotc,ZDOTC)( - const int* n, + void F77_BLAS_MANGLE(zdotc,ZDOTC)( + std::complex* result, const int* n, const std::complex x[], const int* incx, const std::complex y[], const int* incy); } @@ -35,13 +35,23 @@ int main() { TWO = std::complex(0.0,2.0); f[0] = ONE; f[1] = TWO; - std::complex ret - = F77_BLAS_MANGLE(zdotc,ZDOTC)(&NUM, f, &INC, f, &INC); + std::complex ret; + F77_BLAS_MANGLE(zdotc,ZDOTC)(&ret, &NUM, f, &INC, f, &INC); return (ret.real() == double(5.0) ? 0 : 1); } " ) - CHECK_CXX_SOURCE_RUNS("${SOURCE}" ${VARNAME}) +# Test whether the above program, which assumes BLAS can give back complex results +# via pointer arguments, compiles and runs correctly. +# If it does, assume that we don't need to get complex results as direct return values, +# which causes -Wreturn-type-c-linkage warnings. +CHECK_CXX_SOURCE_RUNS("${SOURCE}" KK_BLAS_RESULT_AS_POINTER_ARG) + +IF(${KK_BLAS_RESULT_AS_POINTER_ARG}) + SET(VARNAME OFF) +ELSE() + SET(VARNAME ON) +ENDIF() ENDFUNCTION()