Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ elseif(MINGW)
set(CMAKE_COMPILER_IS_MINGW 1)
endif()

# Ensure try_compile sets the include paths (e.g. for Eigen3)
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})

# https://github.com/fish-shell/fish-shell/issues/5865
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("
Expand Down Expand Up @@ -104,6 +107,10 @@ if(CMAKE_TIMING_VERBOSE AND UNIX)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_SOURCE_DIR}/cmake/custom_output.sh")
endif()

# check for allocation functions that return aligned memory
include("${PCL_SOURCE_DIR}/cmake/pcl_alignment.cmake")
PCL_CHECK_FOR_ALIGNMENT()

# check for SSE flags
include("${PCL_SOURCE_DIR}/cmake/pcl_find_sse.cmake")
if(PCL_ENABLE_SSE AND "${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_DEFAULT}")
Expand Down
31 changes: 31 additions & 0 deletions cmake/pcl_alignment.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
# Check for the presence of _mm_malloc() and posix_memalign()
function(PCL_CHECK_FOR_ALIGNMENT)
include(CheckCXXSourceCompiles)
if(NOT DEFINED HAVE_MM_MALLOC)
check_cxx_source_compiles("
// Intel compiler defines an incompatible _mm_malloc signature
#if defined(__INTEL_COMPILER)
#include <malloc.h>
#else
#include <mm_malloc.h>
#endif
int main()
{
void* mem = _mm_malloc (100, 16);
return 0;
}"
HAVE_MM_MALLOC)
endif()

if(NOT DEFINED HAVE_POSIX_MEMALIGN)
check_cxx_source_compiles("
#include <stdlib.h>
int main()
{
void* mem;
return posix_memalign (&mem, 16, 100);
}"
HAVE_POSIX_MEMALIGN)
endif()
endfunction()
23 changes: 0 additions & 23 deletions cmake/pcl_find_sse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,6 @@ function(PCL_CHECK_FOR_SSE)
set(CMAKE_REQUIRED_FLAGS)
set(SSE_LEVEL 0)

check_cxx_source_runs("
// Intel compiler defines an incompatible _mm_malloc signature
#if defined(__INTEL_COMPILER)
#include <malloc.h>
#else
#include <mm_malloc.h>
#endif
int main()
{
void* mem = _mm_malloc (100, 16);
return 0;
}"
HAVE_MM_MALLOC)

check_cxx_source_runs("
#include <stdlib.h>
int main()
{
void* mem;
return posix_memalign (&mem, 16, 100);
}"
HAVE_POSIX_MEMALIGN)

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
set(CMAKE_REQUIRED_FLAGS "-msse4.2")
endif()
Expand Down