dpu-utilities/0006-add-cmake-compile-for-user-binary-and-so.patch
Weifeng Su fe851cd555 Sync patches from source
The change in patches:
1. Fix cache issue when recreate file
2. Introduce CMAKE to build userspace apps
3. CleanCode

Signed-off-by: Weifeng Su <suweifeng1@huawei.com>
2023-06-12 08:24:22 +00:00

56 lines
2.3 KiB
Diff

From fbde8e2d0b6f66daf7aacb7348dffb97721bca7c Mon Sep 17 00:00:00 2001
From: liqiang <liqiang64@huawei.com>
Date: Thu, 8 Jun 2023 15:58:09 +0800
Subject: add cmake compile for user binary and so
Signed-off-by: liqiang <liqiang64@huawei.com>
---
qtfs/CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 qtfs/CMakeLists.txt
diff --git a/qtfs/CMakeLists.txt b/qtfs/CMakeLists.txt
new file mode 100644
index 0000000..d5b65ec
--- /dev/null
+++ b/qtfs/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(qtfs)
+
+set(CMAKE_C_FLAGS "-g -O2 -fstack-protector-strong -fPIE -pie -fPIC -D_FORTIFY_SOURCE=2 -s -Wl,-z,now -Wl,-z,noexecstack")
+
+# Build rexec and rexec_server
+add_executable(rexec rexec/rexec.c rexec/rexec_sock.c)
+add_executable(rexec_server rexec/rexec_server.c rexec/rexec_sock.c rexec/rexec_shim.c)
+target_include_directories(rexec_server PRIVATE /usr/include/glib-2.0 /usr/lib64/glib-2.0/include)
+target_link_libraries(rexec PRIVATE json-c)
+target_link_libraries(rexec_server PRIVATE json-c glib-2.0)
+
+# Build udsproxyd and libudsproxy.so
+add_executable(udsproxyd ipc/uds_event.c ipc/uds_main.c)
+add_library(udsproxy SHARED ipc/uds_connector.c)
+target_include_directories(udsproxyd PRIVATE include/ /usr/include/glib-2.0 /usr/lib64/glib-2.0/include)
+target_link_libraries(udsproxyd PRIVATE pthread glib-2.0)
+
+# Build engine
+add_executable(engine ipc/uds_main.c ipc/uds_event.c qtfs_common/user_engine.c)
+target_include_directories(engine PRIVATE include/ ./ ipc/ /usr/include/glib-2.0 /usr/lib64/glib-2.0/include)
+target_link_libraries(engine PRIVATE glib-2.0 pthread)
+target_compile_options(engine PRIVATE "-DQTFS_SERVER")
+
+if(DEFINED UDS_TEST_MODE OR DEFINED QTFS_TEST_MODE)
+target_compile_options(engine PRIVATE "-DUDS_TEST_MODE")
+target_compile_options(udsproxyd PRIVATE "-DUDS_TEST_MODE")
+message(WARNING "Important risk warning: the test mode is turned on, and qtfs will expose the network port, \
+ which will bring security risks and is only for testing! If you do not understand the risks,\
+ please don't use or compile again without test mode macro!")
+endif()
+
+set(ignoreMe "${QTFS_TEST_MODE}${UDS_TEST_MODE}")
\ No newline at end of file
--
2.33.0