lib_rats.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (c) 2022 Intel Corporation
  2. # Copyright (c) 2020-2021 Alibaba Cloud
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. set (LIB_RATS_DIR ${CMAKE_CURRENT_LIST_DIR})
  5. if ("$ENV{SGX_SSL_DIR}" STREQUAL "")
  6. set (SGX_SSL_DIR "/opt/intel/sgxssl")
  7. else()
  8. set (SGX_SSL_DIR $ENV{SGX_SSL_DIR})
  9. endif()
  10. if (NOT EXISTS ${SGX_SSL_DIR})
  11. message(FATAL_ERROR "Can not find SGX_SSL, please install it first")
  12. endif()
  13. add_definitions (-DWASM_ENABLE_LIB_RATS=1)
  14. include_directories(${LIB_RATS_DIR} ${SGX_SSL_DIR}/include)
  15. include(FetchContent)
  16. set(RATS_BUILD_MODE "sgx"
  17. CACHE INTERNAL "Select build mode for librats(host|occlum|sgx|wasm)")
  18. set(RATS_INSTALL_PATH "${CMAKE_BINARY_DIR}/librats" CACHE INTERNAL "")
  19. set(BUILD_SAMPLES OFF CACHE BOOL "Disable de compilation of the librats samples" FORCE)
  20. FetchContent_Declare(
  21. librats
  22. GIT_REPOSITORY https://github.com/inclavare-containers/librats
  23. GIT_TAG master
  24. )
  25. FetchContent_GetProperties(librats)
  26. if (NOT librats_POPULATED)
  27. message("-- Fetching librats ..")
  28. FetchContent_Populate(librats)
  29. include_directories("${librats_SOURCE_DIR}/include")
  30. # Prevent the propagation of the CMAKE_C_FLAGS of WAMR into librats
  31. set(SAVED_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
  32. set(CMAKE_C_FLAGS "")
  33. # Import the building scripts of librats
  34. add_subdirectory(${librats_SOURCE_DIR} ${librats_BINARY_DIR} EXCLUDE_FROM_ALL)
  35. # Restore the CMAKE_C_FLAGS of WAMR
  36. set(CMAKE_C_FLAGS ${SAVED_CMAKE_C_FLAGS})
  37. endif()
  38. file (GLOB source_all ${LIB_RATS_DIR}/*.c)
  39. set (LIB_RATS_SOURCE ${source_all})