CMakeLists.txt 2.7 KB

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