[CMAKE]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 29 Mar 2012 15:57:55 +0000 (15:57 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 29 Mar 2012 15:57:55 +0000 (15:57 +0000)
Cleanup *idl-support.cmake files a bit more

svn path=/trunk/; revision=56279

reactos/cmake/midl-support.cmake
reactos/cmake/widl-support.cmake

index 930e7c5..d4543b9 100644 (file)
@@ -1,21 +1,12 @@
 
 #idl files support
-    set(IDL_COMPILER midl)
-    set(IDL_HEADER_ARG /h) #.h
-    set(IDL_HEADER_ARG2 /h) #.h
-    set(IDL_TYPELIB_ARG /tlb) #.tlb
-    set(IDL_SERVER_ARG /sstub) #.c for stub server library
-    set(IDL_CLIENT_ARG /cstub) #.c for stub client library
-    set(IDL_PROXY_ARG /proxy)
-    set(IDL_INTERFACE_ARG /iid)
-    if(ARCH MATCHES i386)
-        set(IDL_FLAGS /nologo /win32 /no_def_idir)
-    elseif(ARCH MATCHES amd64)
-        set(IDL_FLAGS /nologo /amd64 /no_def_idir)
-    else()
-        set(IDL_FLAGS /nologo /no_def_idir)
-    endif()
-    set(IDL_DEPENDS "")
+if(ARCH MATCHES i386)
+    set(IDL_FLAGS /nologo /win32 /no_def_idir)
+elseif(ARCH MATCHES amd64)
+    set(IDL_FLAGS /nologo /amd64 /no_def_idir)
+else()
+    set(IDL_FLAGS /nologo /no_def_idir)
+endif()
 
 function(add_typelib)
     get_includes(INCLUDES)
@@ -24,9 +15,8 @@ function(add_typelib)
         get_filename_component(NAME ${FILE} NAME_WE)
         add_custom_command(
             OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_TYPELIB_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS})
-        list(APPEND OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb)
+            COMMAND midl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} /tlb ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
     endforeach()
 endfunction()
 
@@ -38,8 +28,8 @@ function(add_idl_headers TARGET)
         set(HEADER ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h)
         add_custom_command(
             OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS})
+            COMMAND midl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} /h ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
         list(APPEND HEADERS ${HEADER})
     endforeach()
     add_custom_target(${TARGET} DEPENDS ${HEADERS})
@@ -48,38 +38,17 @@ endfunction()
 function(add_rpcproxy_files)
     get_includes(INCLUDES)
     get_defines(DEFINES)
-
-    if(MSVC)
-        set(DLLDATA_ARG /dlldata ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c)
-        set(OUTPUT_FILES "")
-    endif()
+    set(OUTPUT_FILES "")
     foreach(FILE ${ARGN})
         get_filename_component(NAME ${FILE} NAME_WE)
-        if(MSVC)
-            add_custom_command(
-                OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
-                COMMAND midl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} /proxy ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c /h ${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} /dlldata ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
-                DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${OUTPUT_FILES})
-            list(APPEND OUTPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c)
-            list(APPEND OUTPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h)
-        else()
-            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)
-        endif()
-    endforeach()
-
-    # Extra pass to generate dlldata
-    if(MSVC)
-        set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES GENERATED TRUE)
-    else()
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} --dlldata-only -o ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${IDLS}
-            DEPENDS ${IDLS} ${IDL_DEPENDS})
-    endif()
+            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
+            COMMAND midl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} /proxy ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c /h ${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} /dlldata ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${OUTPUT_FILES})
+        list(APPEND OUTPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c)
+        list(APPEND OUTPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h)
+    endforeach()
+    set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES GENERATED TRUE)
 endfunction()
 
 function(add_rpc_files __type)
@@ -87,24 +56,24 @@ function(add_rpc_files __type)
     get_defines(DEFINES)
     # Is it a client or server module?
     if(__type STREQUAL server)
-        set(__server_client ${IDL_SERVER_ARG})
+        set(__server_client /sstub)
         set(__suffix _s)
     elseif(__type STREQUAL client)
-        set(__server_client ${IDL_CLIENT_ARG})
+        set(__server_client /cstub)
         set(__suffix _c)
     else()
         message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files")
     endif()
     foreach(FILE ${ARGN})
         get_filename_component(__name ${FILE} NAME_WE)
-        set(__name ${__name}${__suffix})
+        set(__name ${CMAKE_CURRENT_BINARY_DIR}/${__name}${__suffix})
         if(NOT IS_ABSOLUTE ${FILE})
             set(FILE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
         endif()
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${__name}.c ${CMAKE_CURRENT_BINARY_DIR}/${__name}.h
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG2} ${CMAKE_CURRENT_BINARY_DIR}/${__name}.h ${__server_client} ${CMAKE_CURRENT_BINARY_DIR}/${__name}.c ${FILE}
-            DEPENDS ${FILE} ${IDL_DEPENDS})
+            OUTPUT ${__name}.c ${__name}.h
+            COMMAND midl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} /h ${__name}.h ${__server_client} ${__name}.c ${FILE}
+            DEPENDS ${FILE})
     endforeach()
 endfunction()
 
@@ -120,8 +89,8 @@ function(generate_idl_iids IDL_FILE)
     get_filename_component(NAME ${IDL_FILE} NAME_WE)
     add_custom_command(
         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c
-        COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_INTERFACE_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c ${IDL_FILE_FULL}
-        DEPENDS ${IDL_FILE_FULL} ${IDL_DEPENDS})
+        COMMAND midl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} /iid ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c ${IDL_FILE_FULL}
+        DEPENDS ${IDL_FILE_FULL})
     set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c PROPERTIES GENERATED TRUE)
 endfunction()
 
index e2c4790..9a42fa2 100644 (file)
@@ -1,21 +1,12 @@
 
 #idl files support
-    set(IDL_COMPILER native-widl)
-    set(IDL_HEADER_ARG -h -o) #.h
-    set(IDL_HEADER_ARG2 -h -H) #.h
-    set(IDL_TYPELIB_ARG -t -o) #.tlb
-    set(IDL_SERVER_ARG -Oif -s -o) #.c for server library
-    set(IDL_CLIENT_ARG -Oif -c -o) #.c for stub client library
-    set(IDL_PROXY_ARG -p -o)
-    set(IDL_INTERFACE_ARG -u -o)
-    if(ARCH MATCHES i386)
-        set(IDL_FLAGS -m32 --win32)
-    elseif(ARCH MATCHES amd64)
-        set(IDL_FLAGS -m64 --win64)
-    else()
-        set(IDL_FLAGS "")
-    endif()
-    set(IDL_DEPENDS native-widl)
+if(ARCH MATCHES i386)
+    set(IDL_FLAGS -m32 --win32)
+elseif(ARCH MATCHES amd64)
+    set(IDL_FLAGS -m64 --win64)
+else()
+    set(IDL_FLAGS "")
+endif()
 
 function(add_typelib)
     get_includes(INCLUDES)
@@ -24,8 +15,8 @@ function(add_typelib)
         get_filename_component(NAME ${FILE} NAME_WE)
         add_custom_command(
             OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_TYPELIB_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS})
+            COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -t -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} native-widl)
         list(APPEND OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb)
     endforeach()
 endfunction()
@@ -38,8 +29,8 @@ function(add_idl_headers TARGET)
         set(HEADER ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h)
         add_custom_command(
             OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS})
+            COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} native-widl)
         list(APPEND HEADERS ${HEADER})
     endforeach()
     add_custom_target(${TARGET} DEPENDS ${HEADERS})
@@ -49,37 +40,20 @@ function(add_rpcproxy_files)
     get_includes(INCLUDES)
     get_defines(DEFINES)
 
-    if(MSVC)
-        set(DLLDATA_ARG /dlldata ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c)
-        set(OUTPUT_FILES "")
-    endif()
     foreach(FILE ${ARGN})
         get_filename_component(NAME ${FILE} NAME_WE)
-        if(MSVC)
-            add_custom_command(
-                OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
-                COMMAND midl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} /proxy ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c /h ${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} /dlldata ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
-                DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${OUTPUT_FILES})
-            list(APPEND OUTPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c)
-            list(APPEND OUTPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h)
-        else()
             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)
-        endif()
     endforeach()
 
     # Extra pass to generate dlldata
-    if(MSVC)
-        set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES GENERATED TRUE)
-    else()
-        add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} --dlldata-only -o ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${IDLS}
-            DEPENDS ${IDLS} ${IDL_DEPENDS})
-    endif()
+    add_custom_command(
+        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
+        COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} --dlldata-only -o ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${IDLS}
+        DEPENDS ${IDLS} native-widl)
 endfunction()
 
 function(add_rpc_files __type)
@@ -87,24 +61,24 @@ function(add_rpc_files __type)
     get_defines(DEFINES)
     # Is it a client or server module?
     if(__type STREQUAL server)
-        set(__server_client ${IDL_SERVER_ARG})
+        set(__server_client -Oif -s -o)
         set(__suffix _s)
     elseif(__type STREQUAL client)
-        set(__server_client ${IDL_CLIENT_ARG})
+        set(__server_client -Oif -c -o)
         set(__suffix _c)
     else()
         message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files")
     endif()
     foreach(FILE ${ARGN})
         get_filename_component(__name ${FILE} NAME_WE)
-        set(__name ${__name}${__suffix})
+        set(__name ${CMAKE_CURRENT_BINARY_DIR}/${__name}${__suffix})
         if(NOT IS_ABSOLUTE ${FILE})
             set(FILE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
         endif()
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${__name}.c ${CMAKE_CURRENT_BINARY_DIR}/${__name}.h
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG2} ${CMAKE_CURRENT_BINARY_DIR}/${__name}.h ${__server_client} ${CMAKE_CURRENT_BINARY_DIR}/${__name}.c ${FILE}
-            DEPENDS ${FILE} ${IDL_DEPENDS})
+            OUTPUT ${__name}.c ${__name}.h
+            COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -H ${__name}.h ${__server_client} ${__name}.c ${FILE}
+            DEPENDS ${FILE} native-widl)
     endforeach()
 endfunction()
 
@@ -120,8 +94,8 @@ function(generate_idl_iids IDL_FILE)
     get_filename_component(NAME ${IDL_FILE} NAME_WE)
     add_custom_command(
         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c
-        COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_INTERFACE_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c ${IDL_FILE_FULL}
-        DEPENDS ${IDL_FILE_FULL} ${IDL_DEPENDS})
+        COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -u -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c ${IDL_FILE_FULL}
+        DEPENDS ${IDL_FILE_FULL} native-widl)
     set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c PROPERTIES GENERATED TRUE)
 endfunction()