[WIN32K]
[reactos.git] / reactos / cmake / midl-support.cmake
index 23973e5..13f7be8 100644 (file)
@@ -1,8 +1,8 @@
 
 #idl files support
-if(ARCH MATCHES i386)
+if(ARCH STREQUAL "i386")
     set(IDL_FLAGS /nologo /win32 /no_def_idir)
-elseif(ARCH MATCHES amd64)
+elseif(ARCH STREQUAL "amd64")
     set(IDL_FLAGS /nologo /amd64 /no_def_idir)
 else()
     set(IDL_FLAGS /nologo /no_def_idir)
@@ -25,10 +25,9 @@ function(add_idl_headers TARGET)
     get_defines(_defines)
     foreach(_idl_file ${ARGN})
         get_filename_component(_name_we ${_idl_file} NAME_WE)
-        #set(_name ${CMAKE_CURRENT_BINARY_DIR}/${_name_we})
         add_custom_command(
-            OUTPUT ${_name_we}.h ${_name_we}_dummy_i.c
-            COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /h ${_name_we}.h /iid ${_name_we}_dummy_i.c ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}
+            OUTPUT ${_name_we}.h
+            COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /h ${_name_we}.h /client none /server none /iid ${_name_we}_dummy_i.c ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}
             DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file})
         list(APPEND _target_dependencies ${_name_we}.h)
     endforeach()
@@ -38,60 +37,64 @@ endfunction()
 function(add_rpcproxy_files)
     get_includes(_includes)
     get_defines(_defines)
-    set(_output_files "")
+    set(_chain_dependency "")
+    set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES GENERATED TRUE)
     foreach(_idl_file ${ARGN})
         get_filename_component(_name_we ${_idl_file} NAME_WE)
         add_custom_command(
-            OUTPUT ${_name_we}_p.c ${_name_we}_p.h proxy.dlldata.c
-            COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /proxy ${_name_we}_p.c /h ${_name_we}_p.h /dlldata proxy.dlldata.c ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file} ${_output_files})
-        list(APPEND _output_files ${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_p.c)
-        list(APPEND _output_files ${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_p.h)
+            OUTPUT ${_name_we}_p.c ${_name_we}_p.h
+            COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /client none /server none /proxy ${_name_we}_p.c /h ${_name_we}_p.h /dlldata proxy.dlldata.c ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file} ${_chain_dependency})
+        list(APPEND _chain_dependency ${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_p.c)
+        list(APPEND _chain_dependency ${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_p.h)
+        set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file})
     endforeach()
-    set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES GENERATED TRUE)
 endfunction()
 
 function(add_rpc_files _type)
     get_includes(_includes)
     get_defines(_defines)
     # Is it a client or server module?
-    if(_type STREQUAL server)
+    if(_type STREQUAL "server")
         set(_server_client /sstub)
         set(_suffix _s)
-    elseif(_type STREQUAL client)
+        set(_prevent_second_type /client none)
+    elseif(_type STREQUAL "client")
         set(_server_client /cstub)
         set(_suffix _c)
+        set(_prevent_second_type /server none)
     else()
         message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files")
     endif()
-    foreach(FILE ${ARGN})
-        get_filename_component(_name_we ${FILE} NAME_WE)
-        set(_name_we ${CMAKE_CURRENT_BINARY_DIR}/${_name_we}${_suffix})
-        if(NOT IS_ABSOLUTE ${FILE})
-            set(FILE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
+    foreach(_idl_file ${ARGN})
+        if(NOT IS_ABSOLUTE ${_idl_file})
+            set(_idl_file ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file})
         endif()
+        get_filename_component(_name_we ${_idl_file} NAME_WE)
+        set(_name_we ${_name_we}${_suffix})
         add_custom_command(
             OUTPUT ${_name_we}.c ${_name_we}.h
-            COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /h ${_name_we}.h ${_server_client} ${_name_we}.c ${FILE}
-            DEPENDS ${FILE})
+            COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /h ${_name_we}.h ${_server_client} ${_name_we}.c ${_prevent_second_type} ${_idl_file}
+            DEPENDS ${_idl_file})
     endforeach()
 endfunction()
 
-function(generate_idl_iids _idl_file)
-    get_includes(_includes)
-    get_defines(_defines)
+function(generate_idl_iids)
+    foreach(_idl_file ${ARGN})
+        get_includes(_includes)
+        get_defines(_defines)
 
-    get_filename_component(_name ${_idl_file} NAME)
-    if(_name STREQUAL "${_idl_file}")
-        set(_idl_file "${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}")
-    endif()
+        if(NOT IS_ABSOLUTE ${_idl_file})
+            set(_idl_file "${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}")
+        endif()
 
-    get_filename_component(_name_we ${_idl_file} NAME_WE)
-    add_custom_command(
-        OUTPUT ${_name_we}_i.c ${_name_we}_i.h
-        COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /h ${_name_we}_i.h /iid ${_name_we}_i.c ${_idl_file}
-        DEPENDS ${_idl_file})
-    set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_i.c PROPERTIES GENERATED TRUE)
+        get_filename_component(_name_we ${_idl_file} NAME_WE)
+        add_custom_command(
+            OUTPUT ${_name_we}_i.c ${_name_we}_i.h
+            COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /h ${_name_we}_i.h /client none /server none /iid ${_name_we}_i.c /proxy ${_name_we}_dummy_p.c ${_idl_file}
+            DEPENDS ${_idl_file})
+        set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_i.c PROPERTIES GENERATED TRUE)
+    endforeach()
 endfunction()
 
 function(add_iid_library _target)
@@ -104,7 +107,7 @@ function(add_iid_library _target)
     add_library(${_target} ${_iid_sources})
 
     # for wtypes.h
-       add_dependencies(${_target} psdk)
+    add_dependencies(${_target} psdk)
 
     set_target_properties(${_target} PROPERTIES EXCLUDE_FROM_ALL TRUE)
 endfunction()