[CMAKE]
authorJérôme Gardou <jerome.gardou@reactos.org>
Sun, 15 May 2011 18:10:27 +0000 (18:10 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Sun, 15 May 2011 18:10:27 +0000 (18:10 +0000)
  - refactor generation of rpcproxy file to avoid recompiling
Get rid of unnecessary libraries in the process.
Tested with both mingw32-make+widl/nmake+midl
  - do not rebuild livecd hives if not necessary

svn path=/branches/cmake-bringup/; revision=51771

CMakeLists.txt
boot/bootdata/CMakeLists.txt
cmake/idl-support.cmake
dll/directx/quartz/CMakeLists.txt
dll/win32/actxprxy/CMakeLists.txt
dll/win32/ole32/CMakeLists.txt
dll/win32/oleaut32/CMakeLists.txt
dll/win32/qmgrprxy/CMakeLists.txt
dll/win32/sti/CMakeLists.txt
dll/win32/urlmon/CMakeLists.txt

index 90c2f79..d1f8eb3 100644 (file)
@@ -21,7 +21,7 @@ set(CMAKE_SHARED_LIBRARY_PREFIX "")
 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
 set(CMAKE_COLOR_MAKEFILE OFF)
-set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
+#set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
 
 if(NOT ARCH)
     set(ARCH i386)
index 62eff1c..edf577b 100644 (file)
@@ -12,10 +12,22 @@ list(APPEND CD_HIVES
     ${CMAKE_CURRENT_SOURCE_DIR}/livecd.inf
     ${CMAKE_CURRENT_SOURCE_DIR}/hiveinst_${ARCH}.inf)
 
-add_custom_target(livecd_hives
-    native-mkhive ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${ARCH} ${CD_HIVES}
+add_custom_command(
+    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sam
+        ${CMAKE_CURRENT_BINARY_DIR}/default
+        ${CMAKE_CURRENT_BINARY_DIR}/security
+        ${CMAKE_CURRENT_BINARY_DIR}/software
+        ${CMAKE_CURRENT_BINARY_DIR}/system
+    COMMAND native-mkhive ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${ARCH} ${CD_HIVES}
     DEPENDS native-mkhive ${CD_HIVES})
 
+add_custom_target(livecd_hives
+    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sam
+        ${CMAKE_CURRENT_BINARY_DIR}/default
+        ${CMAKE_CURRENT_BINARY_DIR}/security
+        ${CMAKE_CURRENT_BINARY_DIR}/software
+        ${CMAKE_CURRENT_BINARY_DIR}/system)
+
 add_cd_file(
     FILE ${CMAKE_CURRENT_BINARY_DIR}/sam
         ${CMAKE_CURRENT_BINARY_DIR}/default
index 7ca6097..04e0022 100644 (file)
@@ -3,12 +3,13 @@
 if(MSVC)
     set(IDL_COMPILER midl)
     set(IDL_HEADER_ARG /h) #.h
-    set(IDL_HEADER_ARG2 /h) #.h
+    set(IDL_HEADER_ARG2 /header) #.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)
+    set(IDL_DLLDATA_ARG /dlldata)
     if(ARCH MATCHES i386)
         set(IDL_FLAGS /win32)
     elseif(ARCH MATCHES amd64)
@@ -19,12 +20,13 @@ if(MSVC)
 else()
     set(IDL_COMPILER native-widl)
     set(IDL_HEADER_ARG -h -o) #.h
-    set(IDL_HEADER_ARG2 -h -H) #.h
+    set(IDL_HEADER_ARG2 -H) #.h
     set(IDL_TYPELIB_ARG -t -o) #.tlb
     set(IDL_SERVER_ARG -s -S) #.c for server library
     set(IDL_CLIENT_ARG -c -C) #.c for stub client library
-    set(IDL_PROXY_ARG -p -P)
+    set(IDL_PROXY_ARG -p -o)
     set(IDL_INTERFACE_ARG -u -o)
+    set(IDL_DLLDATA_ARG --dlldata-only -o)
     if(ARCH MATCHES i386)
         set(IDL_FLAGS -m32 --win32)
     elseif(ARCH MATCHES amd64)
@@ -80,38 +82,42 @@ macro(add_idl_headers TARGET)
     add_custom_target(${TARGET} ALL DEPENDS ${HEADERS})
 endmacro()
 
-macro(add_rpcproxy_library TARGET)
+macro(add_rpcproxy_files)
     get_includes(INCLUDES)
     get_defines(DEFINES)
+
+    if(MSVC)
+        set(DLLDATA_ARG /dlldata ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c)
+    endif()
     foreach(FILE ${ARGN})
         get_filename_component(NAME ${FILE} NAME_WE)
-        if(MSVC)
-            set(IDL_DLLDATA_ARG /dlldata ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_proxy.dlldata.c)
-        else()
-            set(IDL_DLLDATA_ARG "")
+        if(NOT MSVC)
+        # cmake internal dependency checker detects that .c depends on .h.
+        # Building them in two passes avoids unnecessary recompilation (to put it simple)
+        # Fortunately, midl is smarter and generates .h BEFORE .c
+            add_custom_command(
+                OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h
+                COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
+                DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
+            set(_depends ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h)
+            list(APPEND IDLS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
         endif()
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h ${IDL_PROXY_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${IDL_DLLDATA_ARG} ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
-        set_source_files_properties(
-            ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.h ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c
-            PROPERTIES GENERATED TRUE)
-        list(APPEND rpcproxy_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c)
-        list(APPEND IDLS ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.idl)
+            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c
+            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_PROXY_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${IDL_HEADER_ARG2} ${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${DLLDATA_ARG}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${_depends})
     endforeach()
 
-    if(NOT MSVC)
-        # Extra pass to generate dlldata for widl
+    # Extra pass to generate dlldata
+    if(MSVC)
+        #nobody told how to generate it, so mark it as generated
+        set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES GENERATED TRUE)
+    else()
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_proxy.dlldata.c
-            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} --dlldata-only -o ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_proxy.dlldata.c ${IDLS}
+            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})
     endif()
-    set_source_files_properties(
-        ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_proxy.dlldata.c
-        PROPERTIES GENERATED TRUE)
-    add_library(${TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_proxy.dlldata.c ${rpcproxy_SOURCES})
 endmacro()
 
 macro(add_rpc_library TARGET)
@@ -120,7 +126,11 @@ macro(add_rpc_library TARGET)
     foreach(FILE ${ARGN})
         get_filename_component(NAME ${FILE} NAME_WE)
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.h ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.c
+            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.h
+            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
+        add_custom_command(
+            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.c
             COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG2} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.h ${IDL_SERVER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.c ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
             DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
         set_source_files_properties(
@@ -129,7 +139,11 @@ macro(add_rpc_library TARGET)
         list(APPEND server_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.c)
 
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.h ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.c
+            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.h
+            COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
+            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
+        add_custom_command(
+            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.c
             COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG2} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.h ${IDL_CLIENT_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.c ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
             DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
         set_source_files_properties(
index 1cd1ce8..946d73e 100644 (file)
@@ -14,7 +14,7 @@ include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
 
 spec2def(quartz.dll quartz.spec)
 
-add_rpcproxy_library(quartzproxy quartz_strmif.idl)
+add_rpcproxy_files(quartz_strmif.idl)
 
 list(APPEND SOURCE
     avidec.c
@@ -42,6 +42,8 @@ list(APPEND SOURCE
     control.c
     avisplit.c
     version.rc
+    ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
+    ${CMAKE_CURRENT_BINARY_DIR}/quartz_strmif_p.c
     ${CMAKE_CURRENT_BINARY_DIR}/quartz.def)
 
 add_library(quartz SHARED ${SOURCE})
@@ -49,7 +51,6 @@ add_library(quartz SHARED ${SOURCE})
 set_module_type(quartz win32dll)
 
 target_link_libraries(quartz
-    quartzproxy
     strmiids
     uuid
     wine
index 6adff60..41b0eb8 100644 (file)
@@ -4,7 +4,7 @@ include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
 
 spec2def(actxprxy.dll actxprxy.spec)
 
-add_rpcproxy_library(actxprxylib
+add_rpcproxy_files(
     actxprxy_activscp.idl
     actxprxy_comcat.idl
     actxprxy_docobj.idl
@@ -18,6 +18,17 @@ add_rpcproxy_library(actxprxylib
 
 list(APPEND SOURCE
     usrmarshal.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_activscp_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_comcat_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_docobj_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_hlink_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_htiframe_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_objsafe_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_ocmm_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_servprov_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_shobjidl_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/actxprxy_urlhist_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
     ${CMAKE_CURRENT_BINARY_DIR}/actxprxy.def)
 
 add_library(actxprxy SHARED ${SOURCE})
@@ -25,7 +36,6 @@ add_library(actxprxy SHARED ${SOURCE})
 set_entrypoint(actxprxy 0)
 
 target_link_libraries(actxprxy
-    actxprxylib
     uuid
     wine
     ${PSEH_LIB})
index 7458762..bb8ccfd 100644 (file)
@@ -20,7 +20,7 @@ include_directories(
     ${CMAKE_CURRENT_BINARY_DIR}
     ${REACTOS_SOURCE_DIR}/include/reactos/wine)
 
-add_rpcproxy_library(ole32proxy
+add_rpcproxy_files(
     dcom.idl
     ole32_unknwn.idl
     ole32_objidl.idl
@@ -65,7 +65,12 @@ list(APPEND SOURCE
     usrmarshal.c
     ole32res.rc
     ${CMAKE_CURRENT_BINARY_DIR}/dcom_i.c
+    ${CMAKE_CURRENT_BINARY_DIR}/dcom_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/ole32_unknwn_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/ole32_objidl_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/ole32_oleidl_p.c
     ${CMAKE_CURRENT_BINARY_DIR}/ole32_stubs.c
+    ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
     ${CMAKE_CURRENT_BINARY_DIR}/ole32.def)
 
 add_library(ole32 SHARED ${SOURCE})
@@ -73,7 +78,6 @@ add_library(ole32 SHARED ${SOURCE})
 set_module_type(ole32 win32dll)
 
 target_link_libraries(ole32
-    ole32proxy
     wine
     irotrpc
     uuid
index 9b38903..1a27084 100644 (file)
@@ -20,6 +20,9 @@ list(APPEND SOURCE
     vartype.c
     oleaut32.rc
     ${CMAKE_CURRENT_BINARY_DIR}/oleaut32_stubs.c
+    ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
+    ${CMAKE_CURRENT_BINARY_DIR}/oleaut32_oaidl_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/oleaut32_ocidl_p.c
     ${CMAKE_CURRENT_BINARY_DIR}/oleaut32.def)
 
 remove_definitions(-D_WIN32_WINNT=0x502)
@@ -47,14 +50,13 @@ include_directories(
 
 spec2def(oleaut32.dll oleaut32.spec)
 
-add_rpcproxy_library(oleaut32proxy oleaut32_oaidl.idl oleaut32_ocidl.idl)
+add_rpcproxy_files(oleaut32_oaidl.idl oleaut32_ocidl.idl)
 
 add_library(oleaut32 SHARED ${SOURCE})
 
 set_module_type(oleaut32 win32dll)
 
 target_link_libraries(oleaut32
-    oleaut32proxy
     wine
     wineldr
     uuid
index 558a0cf..c43b631 100644 (file)
@@ -12,13 +12,15 @@ spec2def(qmgrprxy.dll qmgrprxy.spec)
 list(APPEND SOURCE
     version.rc
     ${CMAKE_CURRENT_BINARY_DIR}/qmgrprxy_i.c
+    ${CMAKE_CURRENT_BINARY_DIR}/qmgrprxy_p.c
+    ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
     ${CMAKE_CURRENT_BINARY_DIR}/qmgrprxy.def)
 
-add_rpcproxy_library(qmgrprxylib qmgrprxy.idl)
+add_rpcproxy_files(qmgrprxy.idl)
 
 add_library(qmgrprxy SHARED ${SOURCE})
 
 set_module_type(qmgrprxy win32dll)
-target_link_libraries(qmgrprxy qmgrprxylib ${PSEH_LIB} wine)
+target_link_libraries(qmgrprxy ${PSEH_LIB} wine)
 add_importlibs(qmgrprxy rpcrt4 msvcrt kernel32 ntdll)
 add_cd_file(TARGET qmgrprxy DESTINATION reactos/system32 FOR all)
index fea46a9..9a06b70 100644 (file)
@@ -16,16 +16,17 @@ list(APPEND SOURCE
     regsvr.c
     sti.c
     sti_main.c
+    ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
+    ${CMAKE_CURRENT_BINARY_DIR}/sti_wia_p.c
     ${CMAKE_CURRENT_BINARY_DIR}/sti.def)
 
-add_rpcproxy_library(stiproxy sti_wia.idl)
+add_rpcproxy_files(sti_wia.idl)
 
 add_library(sti SHARED ${SOURCE})
 
 set_entrypoint(sti 0)
 
 target_link_libraries(sti
-    stiproxy
     wine
     uuid
     ${PSEH_LIB})
index ad9533a..76abc28 100644 (file)
@@ -10,7 +10,7 @@ set_rc_compiler()
 
 spec2def(urlmon.dll urlmon.spec)
 
-add_rpcproxy_library(urlmonproxy urlmon_urlmon.idl)
+add_rpcproxy_files(urlmon_urlmon.idl)
 
 list(APPEND SOURCE
     bindctx.c
@@ -36,6 +36,8 @@ list(APPEND SOURCE
     urlmon_main.c
     usrmarshal.c
     rsrc.rc
+    ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
+    ${CMAKE_CURRENT_BINARY_DIR}/urlmon_urlmon_p.c
     ${CMAKE_CURRENT_BINARY_DIR}/urlmon_stubs.c
     ${CMAKE_CURRENT_BINARY_DIR}/urlmon.def)
 
@@ -45,7 +47,6 @@ add_library(urlmon SHARED ${SOURCE})
 set_module_type(urlmon win32dll)
 
 target_link_libraries(urlmon
-    urlmonproxy
     uuid
     wine
     ${PSEH_LIB})