- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,When I use SGX SDK,It use makefile to compile a SGX application, and Is it possible to use cmake to complie a SGX application?Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi dai
Of course, You can use any auto build system. If you want to use cmake, you need to add SGX related operations, to cmakelist file. For example, the operation to generate trust and untrust bridge code and operation to sign the enclave ...If you are familiar with cmake you can try that. I'am not familiar with cmake, But it should be something like this.
#APP cmakelist
cmake_minimum_required(VERSION 3.5) add_custom_command(OUTPUT Enclave_u.h Enclave_u.c COMMAND $ENV{SGX_SDK}/bin/x64/sgx_edger8r --untrusted ../Enclave/Enclave.edl --search-path . --search-path /opt/sgxsdk/include COMMENT "make ucode" ) add_custom_target( ucode ALL DEPENDS Enclave_u.h Enclave_u.c ) aux_source_directory(. srcs) add_executable(app ${srcs})
#Enclave cmakelist
cmake_minimum_required(VERSION 3.5) message(STATUS "dealing with .edl") include_directories(. $ENV{SGX_SDK}/include ../Include $ENV{SGX_SDK}/include/tlibc $ENV{SGX_SDK}/include/libcxx) #execute_process(COMMAND $ENV{SGX_SDK}/bin/x64/sgx_edger8r --trusted ./Enclave.edl --search-path . --search-path /opt/sgxsdk/include) add_custom_command(OUTPUT Enclave_t.h Enclave_t.c COMMAND $ENV{SGX_SDK}/bin/x64/sgx_edger8r --trusted ./Enclave.edl --search-path . --search-path /opt/sgxsdk/include COMMENT "make tcode" ) add_custom_target( tcode ALL DEPENDS Enclave_t.h Enclave_t.c ) add_custom_target() aux_source_directory(. enclave_srcs) aux_source_directory(./Edger8rSyntax edger_src) aux_source_directory(./TrustedLibrary tlib_src) message(STATUS, "$ENV{SGX_SDK}/lib64") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L/opt/sgxsdk/lib64 -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 -Wl,--gc-sections -Wl,--version-script=Enclave.lds") SET(CMAKE_C_FLAGS "-m64 -O2 -nostdinc -fvisibility=hidden -fpie -ffunction-sections -fdata-sections -fstack-protector-strong") SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -nostdinc++") add_executable(enclave.so ${enclave_srcs} ${edger_src} ${tlib_src}) target_link_libraries(enclave.so -Wl,--whole-archive sgx_trts -Wl,--no-whole-archive -Wl,--start-group sgx_tstdc sgx_tcxx sgx_tcrypto sgx_tservice -Wl,--end-group)
Regards
you
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi dai
Of course, You can use any auto build system. If you want to use cmake, you need to add SGX related operations, to cmakelist file. For example, the operation to generate trust and untrust bridge code and operation to sign the enclave ...If you are familiar with cmake you can try that. I'am not familiar with cmake, But it should be something like this.
#APP cmakelist
cmake_minimum_required(VERSION 3.5) add_custom_command(OUTPUT Enclave_u.h Enclave_u.c COMMAND $ENV{SGX_SDK}/bin/x64/sgx_edger8r --untrusted ../Enclave/Enclave.edl --search-path . --search-path /opt/sgxsdk/include COMMENT "make ucode" ) add_custom_target( ucode ALL DEPENDS Enclave_u.h Enclave_u.c ) aux_source_directory(. srcs) add_executable(app ${srcs})
#Enclave cmakelist
cmake_minimum_required(VERSION 3.5) message(STATUS "dealing with .edl") include_directories(. $ENV{SGX_SDK}/include ../Include $ENV{SGX_SDK}/include/tlibc $ENV{SGX_SDK}/include/libcxx) #execute_process(COMMAND $ENV{SGX_SDK}/bin/x64/sgx_edger8r --trusted ./Enclave.edl --search-path . --search-path /opt/sgxsdk/include) add_custom_command(OUTPUT Enclave_t.h Enclave_t.c COMMAND $ENV{SGX_SDK}/bin/x64/sgx_edger8r --trusted ./Enclave.edl --search-path . --search-path /opt/sgxsdk/include COMMENT "make tcode" ) add_custom_target( tcode ALL DEPENDS Enclave_t.h Enclave_t.c ) add_custom_target() aux_source_directory(. enclave_srcs) aux_source_directory(./Edger8rSyntax edger_src) aux_source_directory(./TrustedLibrary tlib_src) message(STATUS, "$ENV{SGX_SDK}/lib64") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L/opt/sgxsdk/lib64 -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 -Wl,--gc-sections -Wl,--version-script=Enclave.lds") SET(CMAKE_C_FLAGS "-m64 -O2 -nostdinc -fvisibility=hidden -fpie -ffunction-sections -fdata-sections -fstack-protector-strong") SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -nostdinc++") add_executable(enclave.so ${enclave_srcs} ${edger_src} ${tlib_src}) target_link_libraries(enclave.so -Wl,--whole-archive sgx_trts -Wl,--no-whole-archive -Wl,--start-group sgx_tstdc sgx_tcxx sgx_tcrypto sgx_tservice -Wl,--end-group)
Regards
you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK,Thank you very much!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page