lib_rats.cmake 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright (c) 2022 Intel Corporation
  2. # Copyright (c) 2020-2021 Alibaba Cloud
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. # Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update
  5. # our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt
  6. # from 3rd parties that we should not alter. Therefore, in addition to
  7. # changing the `cmake_minimum_required()`, we should also add a configuration
  8. # here that is compatible with earlier versions.
  9. set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
  10. set (LIB_RATS_DIR ${CMAKE_CURRENT_LIST_DIR})
  11. if ("$ENV{SGX_SSL_DIR}" STREQUAL "")
  12. set (SGX_SSL_DIR "/opt/intel/sgxssl")
  13. else()
  14. set (SGX_SSL_DIR $ENV{SGX_SSL_DIR})
  15. endif()
  16. if (NOT EXISTS ${SGX_SSL_DIR})
  17. message(FATAL_ERROR "Can not find SGX_SSL, please install it first")
  18. endif()
  19. add_definitions (-DWASM_ENABLE_LIB_RATS=1)
  20. include_directories(${LIB_RATS_DIR} ${SGX_SSL_DIR}/include)
  21. include(FetchContent)
  22. set(RATS_BUILD_MODE "sgx"
  23. CACHE INTERNAL "Select build mode for librats(host|occlum|sgx|wasm)")
  24. set(RATS_INSTALL_PATH "${CMAKE_BINARY_DIR}/librats" CACHE INTERNAL "")
  25. set(BUILD_SAMPLES OFF CACHE BOOL "Disable de compilation of the librats samples" FORCE)
  26. FetchContent_Declare(
  27. librats
  28. GIT_REPOSITORY https://github.com/inclavare-containers/librats
  29. GIT_TAG master
  30. )
  31. FetchContent_GetProperties(librats)
  32. if (NOT librats_POPULATED)
  33. message("-- Fetching librats ..")
  34. FetchContent_Populate(librats)
  35. include_directories("${librats_SOURCE_DIR}/include")
  36. # Prevent the propagation of the CMAKE_C_FLAGS of WAMR into librats
  37. set(SAVED_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
  38. set(CMAKE_C_FLAGS "")
  39. # Import the building scripts of librats
  40. add_subdirectory(${librats_SOURCE_DIR} ${librats_BINARY_DIR} EXCLUDE_FROM_ALL)
  41. # Restore the CMAKE_C_FLAGS of WAMR
  42. set(CMAKE_C_FLAGS ${SAVED_CMAKE_C_FLAGS})
  43. endif()
  44. file (GLOB source_all ${LIB_RATS_DIR}/*.c)
  45. set (LIB_RATS_SOURCE ${source_all})