CMakeLists.txt 2.8 KB

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