CMake-Integrated SGX Build Framework
To support the separation of Enclave and App architectures, this framework builds a CMake-compatible compilation system, optimizing modular development, dependency management, and cross-component integration, significantly reducing the complexity of SGX project builds.The following is an example of using this framework.
- Project CmakeList
cmake_minimum_required(VERSION 3.19)
project(http_test "C" "CXX")
set(PROJECT_VERSION 0.0.1)
find_package(ssgx REQUIRED)
add_subdirectory(Enclave)
add_subdirectory(App)
- App CmakeList
set(app "${PROJECT_NAME}_app")
ssgx_add_untrusted_executable(${app}
SRCS
host.cpp
EDL
Enclave.edl
EDL_SEARCH_PATHS
../
${ssgx_EDL_DIRS}
UNTRUSTED_LIBS
ssgx::ssgx_http_u
ssgx::ssgx_log_u
ssgx::ssgx_config_u
ssgx::ssgx_utils_u
ssgx::ssgx_filesystem_u
)
target_compile_features(${app} PRIVATE cxx_std_11)
- Enclave CmakeList
set(enclave "${PROJECT_NAME}_enclave")
ssgx_add_enclave_library(${enclave}
USE_SGXSSL OFF
SRCS
Enclave.cpp
TRUSTED_LIBS
ssgx::ssgx_utils_t
ssgx::ssgx_config_t
ssgx::ssgx_decimal_t
ssgx::ssgx_log_t
ssgx::ssgx_json_t
ssgx::ssgx_http_t
ssgx::ssgx_filesystem_t
EDL Enclave.edl
EDL_SEARCH_PATHS
../
${ssgx_EDL_DIRS}
)
target_compile_features(${enclave} PRIVATE cxx_std_17)
ssgx_enclave_sign(${enclave}
KEY Enclave_private_test.pem
CONFIG Enclave.config.xml
)
important
To use this feature, cmake version must be at least 3.19.