[CMAKE/WIDL] Add rudimentary dependency tracking in add_rpcproxy_files
authorMark Jansen <mark.jansen@reactos.org>
Mon, 15 Jan 2018 20:04:56 +0000 (21:04 +0100)
committerMark Jansen <mark.jansen@reactos.org>
Sat, 20 Jan 2018 14:46:25 +0000 (15:46 +0100)
CORE-14204

sdk/cmake/widl-support.cmake

index 30c4c0b..2674593 100644 (file)
@@ -45,11 +45,22 @@ function(add_rpcproxy_files)
 
     foreach(FILE ${ARGN})
         get_filename_component(NAME ${FILE} NAME_WE)
-            list(APPEND IDLS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
-            add_custom_command(
-                OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h
-                COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c -h -H ${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
-                DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} native-widl)
+        # Most proxy idl's have names like <proxyname>_<original>.idl
+        # We use this to create a dependency from the proxy to the original idl
+        string(REPLACE "_" ";" SPLIT_FILE ${FILE})
+        list(LENGTH SPLIT_FILE len)
+        unset(EXTRA_DEP)
+        if(len STREQUAL "2")
+            list(GET SPLIT_FILE 1 SPLIT_FILE)
+            if(EXISTS "${REACTOS_SOURCE_DIR}/sdk/include/psdk/${SPLIT_FILE}")
+                set(EXTRA_DEP ${REACTOS_SOURCE_DIR}/sdk/include/psdk/${SPLIT_FILE})
+            endif()
+        endif()
+        list(APPEND IDLS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
+        add_custom_command(
+            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h
+            COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c -h -H ${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${EXTRA_DEP} native-widl)
     endforeach()
 
     # Extra pass to generate dlldata