Skip to content

Commit

Permalink
Check newest instruction set first.
Browse files Browse the repository at this point in the history
Only add AVX_FLAGS.
  • Loading branch information
larshg committed Feb 11, 2021
1 parent 5658471 commit 2c10527
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()

if(CMAKE_COMPILER_IS_MSVC)
add_definitions("-DBOOST_ALL_NO_LIB -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -DPCL_ONLY_CORE_POINT_TYPES ${SSE_DEFINITIONS} ${AVX_DEFINITIONS}")
add_definitions("-DBOOST_ALL_NO_LIB -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -DPCL_ONLY_CORE_POINT_TYPES ${SSE_DEFINITIONS}")

add_compile_options(/bigobj)

Expand Down
27 changes: 13 additions & 14 deletions cmake/pcl_find_avx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,8 @@
# Check for the presence of AVX and figure out the flags to use for it.
macro(PCL_CHECK_FOR_AVX)
set(AVX_FLAGS)
set(AVX_DEFINITIONS)

include(CheckCXXSourceRuns)

check_cxx_source_runs("
#include <immintrin.h>
int main()
{
__m256 a;
a = _mm256_set1_ps(0);
return 0;
}"
HAVE_AVX)

check_cxx_source_runs("
#include <immintrin.h>
Expand All @@ -25,14 +14,24 @@ macro(PCL_CHECK_FOR_AVX)
return 0;
}"
HAVE_AVX2)


if(NOT HAVE_AVX2)
check_cxx_source_runs("
#include <immintrin.h>
int main()
{
__m256 a;
a = _mm256_set1_ps(0);
return 0;
}"
HAVE_AVX)
endif()

if(MSVC)
if(HAVE_AVX)
string(APPEND AVX_DEFINITIONS " -D__AVX__")
set(AVX_FLAGS "/arch:AVX")
endif()
if(HAVE_AVX2)
string(APPEND AVX_DEFINITIONS " -D__AVX2__")
set(AVX_FLAGS "/arch:AVX2")
endif()
endif()
Expand Down

0 comments on commit 2c10527

Please sign in to comment.