瀏覽代碼

cmake: Add TomsFastMath support

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 2 年之前
父節點
當前提交
3f33ccf181
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      CMakeLists.txt

+ 12 - 0
CMakeLists.txt

@@ -33,6 +33,7 @@ include(sources.cmake)
 # Options
 #-----------------------------------------------------------------------------
 option(WITH_LTM "Build with support for libtommath" TRUE)
+option(WITH_TFM "Build with support for tomsfastmath" FALSE)
 option(WITH_GMP "Build with support for GNU Multi Precision Arithmetic Library" FALSE)
 set(MPI_PROVIDER "LTM" CACHE STRING "Build tests and demos against 'LTM', 'TFM' or 'GMP', default is LTM")
 option(BUILD_SHARED_LIBS "Build shared library and only the shared library if \"ON\", default is static" OFF)
@@ -138,6 +139,17 @@ if(WITH_LTM)
     target_link_libraries(${PROJECT_NAME} PUBLIC libtommath)
     list(APPEND MPI_PROVIDERS -ltommath)
 endif()
+# tomsfastmath
+if(WITH_TFM)
+    find_package(tomsfastmath 0.13.1 REQUIRED)
+
+    target_compile_definitions(${PROJECT_NAME} PUBLIC TFM_DESC)
+    if(MPI_PROVIDER MATCHES "TFM")
+        target_compile_definitions(${PROJECT_NAME} PUBLIC USE_TFM)
+    endif()
+    target_link_libraries(${PROJECT_NAME} PUBLIC tomsfastmath)
+    list(APPEND MPI_PROVIDERS -ltfm)
+endif()
 # GNU MP
 if(WITH_GMP)
     pkg_check_modules(GMP REQUIRED gmp>=6.1.2)