Skip to content

Commit 20cf199

Browse files
authored
Fix issues when use linux-sgx as cmake subdirectory (#166)
1. Remove the copy of libvmlib.a and libextlib.a to ../enclave_example, which doesn't exist in other project. 2. Use default SGX_SDK path to avoid "source $SGX_SDK/environment". Signed-off-by: Junxian.Xiao <[email protected]>
1 parent 5a10651 commit 20cf199

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

product-mini/platforms/linux-sgx/CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ set (APP_FRAMEWORK_DIR ${WAMR_ROOT_DIR}/core/app-framework)
6464
# include the build config template file
6565
include (${WAMR_ROOT_DIR}/build-scripts/config_common.cmake)
6666

67+
if ("$ENV{SGX_SDK}" STREQUAL "")
68+
set (SGX_SDK_DIR "/opt/intel/sgxsdk")
69+
else()
70+
set (SGX_SDK_DIR $ENV{SGX_SDK})
71+
endif()
72+
6773
include_directories (${SHARED_DIR}/include
6874
${IWASM_DIR}/include
69-
$ENV{SGX_SDK}/include
70-
$ENV{SGX_SDK}/include/tlibc
71-
$ENV{SGX_SDK}/include/libcxx)
75+
${SGX_SDK_DIR}/include
76+
${SGX_SDK_DIR}/include/tlibc
77+
${SGX_SDK_DIR}/include/libcxx)
7278

7379
enable_language (ASM)
7480

@@ -107,7 +113,3 @@ add_library (vmlib
107113
${IWASM_COMPL_SOURCE})
108114

109115
add_library (extlib ext_lib_export.c)
110-
111-
set (copy_libs_cmd cp -a libvmlib.a libextlib.a ../enclave-sample/)
112-
add_custom_target (copy_libs_to_enclave ALL COMMAND ${copy_libs_cmd} DEPENDS vmlib extlib)
113-

product-mini/platforms/linux-sgx/enclave-sample/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ Enclave/%.o: Enclave/%.cpp
170170
@$(CXX) $(Enclave_Cpp_Flags) -c $< -o $@
171171
@echo "CXX <= $<"
172172

173+
libvmlib.a: ../build/libvmlib.a
174+
@cp $< $@
175+
@echo "CP $@ <= $<"
176+
177+
libextlib.a: ../build/libextlib.a
178+
@cp $< $@
179+
@echo "CP $@ <= $<"
180+
173181
$(Enclave_Name): Enclave/Enclave_t.o $(Enclave_Cpp_Objects) libvmlib.a libextlib.a
174182
@$(CXX) $^ -o $@ $(Enclave_Link_Flags)
175183
@echo "LINK => $@"

0 commit comments

Comments
 (0)