Commit 256f237f authored by Rashad Kanavath's avatar Rashad Kanavath

COMP: fix openmp & sse flag checks

parent 76a47998
function(check_sse_features sse_flags )
include(CheckIncludeFile)
include(CheckLibraryExists)
include(CheckCXXSourceRuns)
include(CheckCXXCompilerFlag)
set(has_sse FALSE)
set(${sse_flags} "0" PARENT_SCOPE)
# For apple assume sse2 is on for all intel builds, check for 64 and 32 bit versions
if(APPLE)
......@@ -24,14 +21,11 @@ function(check_sse_features sse_flags )
b = _mm_add_pd(a,a);
_mm_storeu_pd(vals,b);
return 0;
}"
has_sse)
}" HAVE_SSE2_FLAGS)
if(has_sse)
message(STATUS "Performing Test CXX_HAS_SSE2 - Success")
if(HAVE_SSE2_FLAGS)
set(${sse_flags} "-msse2 -mfpmath=sse" PARENT_SCOPE)
else()
message(STATUS "Performing Test CXX_HAS_SSE2 - Failed")
return()
endif()
set(CMAKE_REQUIRED_FLAGS "-msse")
......@@ -46,18 +40,13 @@ function(check_sse_features sse_flags )
b = _mm_add_ps(a,b);
_mm_storeu_ps(vals,b);
return 0;
}"
has_sse)
}" HAVE_SSE_FLAGS)
if(has_sse)
message(STATUS "Performing Test CXX_HAS_SSE - Success")
if(HAVE_SSE_FLAGS)
set(${sse_flags} "-msse -mfpmath=sse" PARENT_SCOPE)
return()
else()
message(STATUS "Performing Test CXX_HAS_SSE - Failed")
return()
endif()
elseif(MSVC)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
return()
......@@ -73,15 +62,14 @@ function(check_sse_features sse_flags )
b = _mm_add_pd(a,a);
_mm_storeu_pd(vals,b);
return 0;
}"
has_sse)
}" HAVE_SSE_FLAGS)
if(has_sse)
message(STATUS "Performing Test CXX_HAS_SSE - Success")
if(HAVE_SSE_FLAGS)
message(STATUS "Performing Test HAVE_SSE_FLAGS - Success")
set(${sse_flags} "/arch:SSE2 /fp:fast -D__SSE__ -D__SSE2__" PARENT_SCOPE)
return()
else()
message(STATUS "Performing Test CXX_HAS_SSE - Failed")
message(STATUS "Performing Test HAVE_SSE_FLAGS - Failed")
return()
endif()
endif()
......
......@@ -281,23 +281,24 @@ macro(check_compiler_platform_flags)
# check for OpenMP
if(OTB_USE_OPENMP)
message(STATUS "OpenMP support requested with OTB_USE_OPENMP=${OTB_USE_OPENMP}")
find_package(OpenMP QUIET)
endif()
if(OPENMP_FOUND)
message(STATUS "Enabling OpenMP support")
set(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} ${OpenMP_C_FLAGS}")
message(STATUS "Adding '${OpenMP_CXX_FLAGS}' to OTB_REQUIRED_CXX_FLAGS ")
set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(STATUS "Disabling OpenMP support")
if(OpenMP_EXE_LINKER_FLAGS)
set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
endif()
set(OTB_SSE_FLAGS)
if(OTB_USE_SSE_FLAGS)
if(OTB_USE_SSE_FLAGS)
message(STATUS "SIMD extensions requested with OTB_USE_SSE_FLAGS=${OTB_USE_SSE_FLAGS}")
include(OTBCheckSSEFeatures)
check_sse_features(OTB_SSE_FLAGS)
if(OTB_SSE_FLAGS)
message(STATUS "Adding OTB_SSE_FLAGS(${OTB_SSE_FLAGS}) to OTB_REQUIRED_CXX_FLAGS")
message(STATUS "Adding '${OTB_SSE_FLAGS}' to OTB_REQUIRED_CXX_FLAGS")
set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${OTB_SSE_FLAGS}")
endif()
endif()
......
......@@ -506,6 +506,8 @@ foreach(otb_option
OTB_WRAP_PYTHON
OTB_WRAP_JAVA
OTB_DATA_ROOT
OTB_USE_OPENMP
OTB_USE_SSE_FLAGS
)
get_white_spaces("${otb_option}" spaces)
message("${otb_option} ${spaces} = ${${otb_option}}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment