optional native compilation.
When linking to other software which also uses Eigen it is important that compiler flags match in order to guarantee alignment of eigen vectors. In order to be more flexible, we should make native compilation optional.
Example:
include(CheckCXXCompilerFlag)
if (NOT BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
else ()
else ()
message(STATUS "Enabling runtime checks")
endif ()
if (BUILD_NATIVE)
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if (COMPILER_SUPPORTS_MARCH_NATIVE)
message(STATUS "Adding compiler flag march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
else ()
message(WARNING "Compiler does not support flag march=native")
endif ()
endif ()