CMakeLists.txt 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. cmake_minimum_required (VERSION 3.5.1)
  2. ### To use gcc/g++ on a Macintosh, you must set the Compilers
  3. ### here, not inside the project
  4. ##if(APPLE)
  5. ## set(CMAKE_C_COMPILER "/usr/local/bin/gcc-7")
  6. ## set(CMAKE_CXX_COMPILER "/usr/local/bin/g++-7")
  7. ##endif()
  8. ### TODO: for now, we use CLang for Mac
  9. ###
  10. ### In order to create OpenFHE's static libraries you should enable
  11. ### the BUILD_STATIC option. For that, you run "cmake .. -DBUILD_STATIC=ON".
  12. ### After having your link completed you will find static libs
  13. ### with the suffix "_static" in ./build/libs/.
  14. ### Examples: OPENFHEpke_static.a, OPENFHEcore_static.a, etc.
  15. ### After you run "make install" in your build directory, you can build your custom application.
  16. ### If you need your application to be linked statically, then run "cmake .. -DBUILD_STATIC=ON"
  17. project(openfhe)
  18. set(CMAKE_CXX_STANDARD 17)
  19. option( BUILD_STATIC "Set to ON to include static versions of the library" OFF)
  20. find_package(OpenFHE)
  21. find_package(pybind11 REQUIRED)
  22. set( CMAKE_CXX_FLAGS ${OpenFHE_CXX_FLAGS} )
  23. set( OpenFHE_Py_SOURCES src)
  24. set( OpenFHE_Py_INCLUDES include)
  25. include_directories( ${OPENMP_INCLUDES} )
  26. include_directories( ${OpenFHE_INCLUDE} )
  27. include_directories( ${OpenFHE_INCLUDE}/third-party/include )
  28. include_directories( ${OpenFHE_INCLUDE}/core )
  29. include_directories( ${OpenFHE_INCLUDE}/pke )
  30. # include_directories( ${OpenFHE_Py_SOURCES} )
  31. include_directories( ${OpenFHE_Py_INCLUDES}/pke )
  32. include_directories( ${OpenFHE_Py_INCLUDES} )
  33. ### add directories for other OpenFHE modules as needed for your project
  34. link_directories( ${OpenFHE_LIBDIR} )
  35. link_directories( ${OPENMP_LIBRARIES} )
  36. if(BUILD_STATIC)
  37. set( CMAKE_EXE_LINKER_FLAGS "${OpenFHE_EXE_LINKER_FLAGS} -static")
  38. link_libraries( ${OpenFHE_STATIC_LIBRARIES} )
  39. else()
  40. set( CMAKE_EXE_LINKER_FLAGS ${OpenFHE_EXE_LINKER_FLAGS} )
  41. link_libraries( ${OpenFHE_SHARED_LIBRARIES} )
  42. endif()
  43. ### ADD YOUR EXECUTABLE(s) HERE
  44. ### add_executable( EXECUTABLE-NAME SOURCES )
  45. ###
  46. ### EXAMPLE:
  47. ### add_executable( test demo-simple-example.cpp )
  48. ### Pybind Modules
  49. pybind11_add_module(openfhe src/bindings.cpp src/pke/decryption.cpp src/pke/serialization.cpp)
  50. ### Python installation
  51. find_package(Python REQUIRED COMPONENTS Interpreter Development)
  52. execute_process(
  53. COMMAND "${Python_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
  54. OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
  55. OUTPUT_STRIP_TRAILING_WHITESPACE
  56. )
  57. message(STATUS "Python site packages directory: ${PYTHON_SITE_PACKAGES}")
  58. install(TARGETS openfhe LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES})