CMakeLists.txt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. cmake_minimum_required (VERSION 3.5.1)
  2. project(openfhe)
  3. set(CMAKE_CXX_STANDARD 17)
  4. option( BUILD_STATIC "Set to ON to include static versions of the library" OFF)
  5. find_package(OpenFHE)
  6. find_package(pybind11 REQUIRED)
  7. set( CMAKE_CXX_FLAGS ${OpenFHE_CXX_FLAGS} )
  8. set( OpenFHE_Py_SOURCES src/lib)
  9. set( OpenFHE_Py_INCLUDES src/include)
  10. include_directories( ${OPENMP_INCLUDES} )
  11. include_directories( ${OpenFHE_INCLUDE} )
  12. include_directories( ${OpenFHE_INCLUDE}/third-party/include )
  13. include_directories( ${OpenFHE_INCLUDE}/core )
  14. include_directories( ${OpenFHE_INCLUDE}/pke )
  15. include_directories( ${OpenFHE_INCLUDE}/binfhe )
  16. # include_directories( ${OpenFHE_Py_SOURCES} )
  17. include_directories( ${OpenFHE_Py_INCLUDES}/pke )
  18. include_directories( ${OpenFHE_Py_INCLUDES}/binfhe )
  19. include_directories( ${OpenFHE_Py_INCLUDES}/docstrings )
  20. include_directories( ${OpenFHE_Py_INCLUDES} )
  21. ### add directories for other OpenFHE modules as needed for your project
  22. link_directories( ${OpenFHE_LIBDIR} )
  23. link_directories( ${OPENMP_LIBRARIES} )
  24. if(BUILD_STATIC)
  25. set( CMAKE_EXE_LINKER_FLAGS "${OpenFHE_EXE_LINKER_FLAGS} -static")
  26. link_libraries( ${OpenFHE_STATIC_LIBRARIES} )
  27. else()
  28. set( CMAKE_EXE_LINKER_FLAGS ${OpenFHE_EXE_LINKER_FLAGS} )
  29. link_libraries( ${OpenFHE_SHARED_LIBRARIES} )
  30. endif()
  31. ### ADD YOUR EXECUTABLE(s) HERE
  32. ### add_executable( EXECUTABLE-NAME SOURCES )
  33. ###
  34. ### EXAMPLE:
  35. ### add_executable( test demo-simple-example.cpp )
  36. ### Pybind Modules
  37. pybind11_add_module(openfhe
  38. src/lib/bindings.cpp
  39. src/lib/binfhe_bindings.cpp
  40. src/lib/binfhe/binfhecontext_wrapper.cpp
  41. src/lib/pke/serialization.cpp
  42. src/lib/pke/cryptocontext_wrapper.cpp
  43. )
  44. ### Python installation
  45. # Allow the user to specify the path to Python executable (if not provided, find it)
  46. option(PYTHON_EXECUTABLE_PATH "Path to Python executable" "")
  47. if(NOT PYTHON_EXECUTABLE_PATH)
  48. # Find Python and its development components
  49. find_package(Python REQUIRED COMPONENTS Interpreter Development)
  50. else()
  51. # Set Python_EXECUTABLE to the specified path
  52. set(Python_EXECUTABLE "${PYTHON_EXECUTABLE_PATH}")
  53. endif()
  54. execute_process(
  55. COMMAND "${Python_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
  56. OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
  57. OUTPUT_STRIP_TRAILING_WHITESPACE
  58. )
  59. message(STATUS "Python site packages directory: ${PYTHON_SITE_PACKAGES}")
  60. install(TARGETS openfhe LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES})