CMakeLists.txt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. include_directories( ${OPENMP_INCLUDES} )
  24. include_directories( ${OpenFHE_INCLUDE} )
  25. include_directories( ${OpenFHE_INCLUDE}/third-party/include )
  26. include_directories( ${OpenFHE_INCLUDE}/core )
  27. include_directories( ${OpenFHE_INCLUDE}/pke )
  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 src/bindings.cpp)
  45. ### Python installation
  46. find_package(Python REQUIRED COMPONENTS Interpreter Development)
  47. execute_process(
  48. COMMAND "${Python_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
  49. OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
  50. OUTPUT_STRIP_TRAILING_WHITESPACE
  51. )
  52. message(STATUS "Python site packages directory: ${PYTHON_SITE_PACKAGES}")
  53. install(TARGETS openfhe LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES})