############################################################################
# CMakeLists.txt file for building ROOT math/vecops package
############################################################################

set(HEADERS
  ROOT/TAdoptAllocator.hxx
  ROOT/TVec.hxx
)

set(SOURCES
  TAdoptAllocator.cxx
  TVec.cxx
)

if(vdt)
  # needed for rootcling, to be removed
  include_directories(${VDT_INCLUDE_DIRS})
endif()

ROOT_STANDARD_LIBRARY_PACKAGE(VecOps
                              HEADERS ${HEADERS}
                              SOURCES ${SOURCES}
                              DICTIONARY_OPTIONS "-writeEmptyRootPCM"
                              DEPENDENCIES Core)

if(vdt)
  target_link_libraries(VecOps Vdt::Vdt)
endif()

target_compile_options(VecOps PRIVATE -Ofast)

ROOT_ADD_TEST_SUBDIRECTORY(test)

############################################################################
# CMakeLists.txt file for building ROOT math/vecops package
############################################################################

set(HEADERS
  ROOT/TAdoptAllocator.hxx
  ROOT/TVec.hxx
)

set(SOURCES
  TAdoptAllocator.cxx
  TVec.cxx
)

if(vdt)
  # needed for rootcling, to be removed
  include_directories(${VDT_INCLUDE_DIRS})
endif()

ROOT_STANDARD_LIBRARY_PACKAGE(VecOps
                              HEADERS ${HEADERS}
                              SOURCES ${SOURCES}
                              DICTIONARY_OPTIONS "-writeEmptyRootPCM"
                              DEPENDENCIES Core)

if(vdt)
  target_link_libraries(VecOps Vdt::Vdt)
endif()

target_compile_options(VecOps PRIVATE -O3)

ROOT_ADD_TEST_SUBDIRECTORY(test)

Drop from -Ofast to -O3 to compile VecOps
Drop from -Ofast to -O3 to compile VecOps

Using -ffast-math is causing linking problems like the one below in the
nightly builds with Clang 7 + GCC 6.2:

CMakeFiles/VecOps.dir/src/TVec.cxx.o: In function `exp':
 /.../include/c++/6.2.0/cmath:246: undefined reference to `__expf_finite'

This is because when linking with -ffast-math, the compiler is expecting
the symbol __expf_finite to be in libm.so, but it is not there:

$ nm -D /lib/libm-2.12.so | grep expf
00012010 W cexpf
00010aa0 W expf
000141d0 W frexpf
00014240 W ldexpf

The vectorized math functions were only introduced in glibc-2.22, so
on a machine with a more recent glibc, however, the symbols are there:

$ nm -D /lib/libm-2.26.so | grep expf
000000000004d5d0 W cexpf
000000000006bbe0 W cexpf128
000000000000f930 W expf
000000000006fb10 W expf128
0000000000050f20 T __expf128_finite
0000000000040de0 T __expf_finite
00000000000489b0 W frexpf
0000000000064080 W frexpf128
0000000000048a60 W ldexpf
00000000000641b0 W ldexpf128

More information: https://sourceware.org/glibc/wiki/libmvec
