From 2425d2e730d1decba801c381521178465da385ac Mon Sep 17 00:00:00 2001
From: tangjie02 <tangjie02@kylinsec.com.cn>
Date: Fri, 23 Sep 2022 17:05:12 +0800
Subject: [PATCH] fix(compile): Fix the probability compile error problem
 caused by multiple targets depending on output files of add_custom_command.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 修复由于多个target依赖了add_custom_command的输出引起的概率性的编译报错问题

Closes #I5NP6A

Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
---
 src/CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f972713..335b677 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,6 +8,8 @@ file(GLOB_RECURSE CORE_CPP_FILES ./*.cpp)
 gen_dbus_stub(CC_DAEMON cc_daemon com.kylinsec.
               ${CMAKE_SOURCE_DIR}/src/com.kylinsec.Kiran.CCDaemon.xml)
 
+add_custom_target(TARGET_CC_DAEMON DEPENDS ${CC_DAEMON_GENERATED_STUB})
+
 configure_file(config.h.in ${PROJECT_BINARY_DIR}/config.h)
 
 if(build-system-daemon)
@@ -28,6 +30,8 @@ if(build-system-daemon)
   target_link_libraries(${TARGET_SYSTEM_DAEMON}
                         PRIVATE ${GMODULE_LIBRARIES} lib-base lib-dbus lib-iso)
 
+  add_dependencies(${TARGET_SYSTEM_DAEMON} TARGET_CC_DAEMON)
+
   install(TARGETS ${TARGET_SYSTEM_DAEMON}
           DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
 
@@ -60,6 +64,8 @@ if(build-session-daemon)
             lib-iso
             lib-display)
 
+  add_dependencies(${TARGET_SESSION_DAEMON} TARGET_CC_DAEMON)
+
   install(TARGETS ${TARGET_SESSION_DAEMON}
           DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
 
-- 
2.33.0

