[ros-diffs] [tkreuzer] 48838: [CMAKE] Create a portable way of compiling IDL files. Sorry for the coding style :)

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Tue Sep 21 02:31:10 UTC 2010


Author: tkreuzer
Date: Tue Sep 21 02:31:09 2010
New Revision: 48838

URL: http://svn.reactos.org/svn/reactos?rev=48838&view=rev
Log:
[CMAKE]
Create a portable way of compiling IDL files.
Sorry for the coding style :)

Modified:
    branches/cmake-bringup/CMakeMacros.cmake
    branches/cmake-bringup/include/psdk/CMakeLists.txt
    branches/cmake-bringup/toolchain-mingw32.cmake
    branches/cmake-bringup/toolchain-msvc.cmake

Modified: branches/cmake-bringup/CMakeMacros.cmake
URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/CMakeMacros.cmake?rev=48838&r1=48837&r2=48838&view=diff
==============================================================================
--- branches/cmake-bringup/CMakeMacros.cmake [iso-8859-1] (original)
+++ branches/cmake-bringup/CMakeMacros.cmake [iso-8859-1] Tue Sep 21 02:31:09 2010
@@ -1,77 +1,116 @@
-
-MACRO(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
-
-    # Add the precompiled header to the build
-    get_filename_component(FILE ${_header_filename} NAME)
-    set(_gch_filename "${_target_name}_${FILE}.gch")
-    list(APPEND ${_out_compile_flags} -c ${_header_filename} -o ${_gch_filename})
-
-    # This gets us our includes
-    get_directory_property(DIRINC INCLUDE_DIRECTORIES)
-    foreach(item ${DIRINC})
-        list(APPEND ${_out_compile_flags} -I${item})
-    endforeach(item) 
-
-    # This is a particular bit of undocumented/hacky magic I'm quite proud of
-    get_directory_property(_compiler_flags DEFINITIONS)
-    string(REPLACE "\ " "\t" _compiler_flags ${_compiler_flags})
-    list(APPEND ${_out_compile_flags} ${_compiler_flags})
-
-    # This gets any specific definitions that were added with set-target-property
-    get_target_property(_target_defs ${_target_name} COMPILE_DEFINITIONS)
-    if (_target_defs)
-        foreach(item ${_target_defs})
-            list(APPEND ${_out_compile_flags} -D${item})
-        endforeach(item)
-    endif()
-
-ENDMACRO(_PCH_GET_COMPILE_FLAGS) 
-
-MACRO(add_pch _target_name _header_filename _src_list)
-    
-    get_filename_component(FILE ${_header_filename} NAME)
-    set(_gch_filename "${_target_name}_${FILE}.gch")
-    list(APPEND ${_src_list} ${_gch_filename})
-    _PCH_GET_COMPILE_FLAGS(${_target_name} _args ${_header_filename})
-    file(REMOVE ${_gch_filename})
-    add_custom_command(
-        OUTPUT ${_gch_filename}
-        COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} ${_args}
-        DEPENDS ${_header_filename})
-
-ENDMACRO(add_pch _target_name _header_filename _src_list)
-
-MACRO(spec2def _target_name _spec_file _def_file)
-
-    add_custom_command(
-        OUTPUT ${_def_file}
-        COMMAND native-winebuild -o ${_def_file} --def -E ${_spec_file} --filename ${_target_name}.dll
-        DEPENDS native-winebuild)
-    set_source_files_properties(${_def_file} PROPERTIES GENERATED TRUE)
-    add_custom_target(${_target_name}_def ALL DEPENDS ${_def_file})
-
-ENDMACRO(spec2def _target_name _spec_file _def_file)
-
-MACRO(CreateBootSectorTarget _target_name _asm_file _object_file)
-
-    get_filename_component(OBJECT_PATH ${_object_file} PATH)
-    file(MAKE_DIRECTORY ${OBJECT_PATH})
-    get_directory_property(defines COMPILE_DEFINITIONS)
-    get_directory_property(includes INCLUDE_DIRECTORIES)
-
-    foreach(arg ${defines})
-        set(result_defs ${result_defs} -D${arg})
-    endforeach(arg ${defines})
-
-    foreach(arg ${includes})
-        set(result_incs -I${arg} ${result_incs})
-    endforeach(arg ${includes})
-
-    add_custom_command(
-        OUTPUT ${_object_file}
-        COMMAND nasm -o ${_object_file} ${result_incs} ${result_defs} -f bin ${_asm_file}
-        DEPENDS native-winebuild)
-    set_source_files_properties(${_object_file} PROPERTIES GENERATED TRUE)
-    add_custom_target(${_target_name} ALL DEPENDS ${_object_file})
-
-ENDMACRO(CreateBootSectorTarget _target_name _asm_file _object_file)
+
+MACRO(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
+
+    # Add the precompiled header to the build
+    get_filename_component(FILE ${_header_filename} NAME)
+    set(_gch_filename "${_target_name}_${FILE}.gch")
+    list(APPEND ${_out_compile_flags} -c ${_header_filename} -o ${_gch_filename})
+
+    # This gets us our includes
+    get_directory_property(DIRINC INCLUDE_DIRECTORIES)
+    foreach(item ${DIRINC})
+        list(APPEND ${_out_compile_flags} -I${item})
+    endforeach(item) 
+
+    # This is a particular bit of undocumented/hacky magic I'm quite proud of
+    get_directory_property(_compiler_flags DEFINITIONS)
+    string(REPLACE "\ " "\t" _compiler_flags ${_compiler_flags})
+    list(APPEND ${_out_compile_flags} ${_compiler_flags})
+
+    # This gets any specific definitions that were added with set-target-property
+    get_target_property(_target_defs ${_target_name} COMPILE_DEFINITIONS)
+    if (_target_defs)
+        foreach(item ${_target_defs})
+            list(APPEND ${_out_compile_flags} -D${item})
+        endforeach(item)
+    endif()
+
+ENDMACRO(_PCH_GET_COMPILE_FLAGS) 
+
+MACRO(add_pch _target_name _header_filename _src_list)
+    
+    get_filename_component(FILE ${_header_filename} NAME)
+    set(_gch_filename "${_target_name}_${FILE}.gch")
+    list(APPEND ${_src_list} ${_gch_filename})
+    _PCH_GET_COMPILE_FLAGS(${_target_name} _args ${_header_filename})
+    file(REMOVE ${_gch_filename})
+    add_custom_command(
+        OUTPUT ${_gch_filename}
+        COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} ${_args}
+        DEPENDS ${_header_filename})
+
+ENDMACRO(add_pch _target_name _header_filename _src_list)
+
+MACRO(spec2def _target_name _spec_file _def_file)
+
+    add_custom_command(
+        OUTPUT ${_def_file}
+        COMMAND native-winebuild -o ${_def_file} --def -E ${_spec_file} --filename ${_target_name}.dll
+        DEPENDS native-winebuild)
+    set_source_files_properties(${_def_file} PROPERTIES GENERATED TRUE)
+    add_custom_target(${_target_name}_def ALL DEPENDS ${_def_file})
+
+ENDMACRO(spec2def _target_name _spec_file _def_file)
+
+if (NOT MSVC)
+MACRO(CreateBootSectorTarget _target_name _asm_file _object_file)
+
+    get_filename_component(OBJECT_PATH ${_object_file} PATH)
+    file(MAKE_DIRECTORY ${OBJECT_PATH})
+    get_directory_property(defines COMPILE_DEFINITIONS)
+    get_directory_property(includes INCLUDE_DIRECTORIES)
+
+    foreach(arg ${defines})
+        set(result_defs ${result_defs} -D${arg})
+    endforeach(arg ${defines})
+
+    foreach(arg ${includes})
+        set(result_incs -I${arg} ${result_incs})
+    endforeach(arg ${includes})
+
+    add_custom_command(
+        OUTPUT ${_object_file}
+        COMMAND nasm -o ${_object_file} ${result_incs} ${result_defs} -f bin ${_asm_file}
+        DEPENDS native-winebuild)
+    set_source_files_properties(${_object_file} PROPERTIES GENERATED TRUE)
+    add_custom_target(${_target_name} ALL DEPENDS ${_object_file})
+
+ENDMACRO(CreateBootSectorTarget _target_name _asm_file _object_file)
+else()
+MACRO(CreateBootSectorTarget _target_name _asm_file _object_file)
+ENDMACRO()
+endif()
+
+MACRO(MACRO_IDL_COMPILE_OBJECT OBJECT SOURCE)
+  GET_PROPERTY(FLAGS SOURCE ${SOURCE} PROPERTY COMPILE_FLAGS)
+  GET_PROPERTY(DEFINES SOURCE ${SOURCE} PROPERTY COMPILE_DEFINITIONS)
+  GET_PROPERTY(INCLUDE_DIRECTORIES DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
+  FOREACH(DIR ${INCLUDE_DIRECTORIES})
+    SET(FLAGS "${FLAGS} -I${DIR}")
+  ENDFOREACH()
+
+  SET(IDL_COMMAND ${CMAKE_IDL_COMPILE_OBJECT})
+  STRING(REPLACE "<CMAKE_IDL_COMPILER>" "${CMAKE_IDL_COMPILER}" IDL_COMMAND "${IDL_COMMAND}")
+  STRING(REPLACE <FLAGS> "${FLAGS}" IDL_COMMAND "${IDL_COMMAND}")
+  STRING(REPLACE "<DEFINES>" "${DEFINES}" IDL_COMMAND "${IDL_COMMAND}")
+  STRING(REPLACE "<OBJECT>" "${OBJECT}" IDL_COMMAND "${IDL_COMMAND}")
+  STRING(REPLACE "<SOURCE>" "${SOURCE}" IDL_COMMAND "${IDL_COMMAND}")
+  SEPARATE_ARGUMENTS(IDL_COMMAND)
+
+  ADD_CUSTOM_COMMAND(
+    OUTPUT ${OBJECT}
+    COMMAND ${IDL_COMMAND}
+    DEPENDS ${SOURCE}
+    VERBATIM
+  )
+ENDMACRO()
+
+MACRO(ADD_INTERFACE_DEFINITIONS TARGET)
+  FOREACH(SOURCE ${ARGN})
+    GET_FILENAME_COMPONENT(FILE ${SOURCE} NAME_WE)
+    SET(OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.h)
+    MACRO_IDL_COMPILE_OBJECT(${OBJECT} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE})
+    LIST(APPEND OBJECTS ${OBJECT})
+  ENDFOREACH()
+  ADD_CUSTOM_TARGET(${TARGET} ALL DEPENDS ${OBJECTS})
+ENDMACRO()

Modified: branches/cmake-bringup/include/psdk/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/include/psdk/CMakeLists.txt?rev=48838&r1=48837&r2=48838&view=diff
==============================================================================
--- branches/cmake-bringup/include/psdk/CMakeLists.txt [iso-8859-1] (original)
+++ branches/cmake-bringup/include/psdk/CMakeLists.txt [iso-8859-1] Tue Sep 21 02:31:09 2010
@@ -1,56 +1,113 @@
 
-MACRO (MACRO_ADD_PSDK_INTERFACES)
+LIST(APPEND SOURCE
+#   access.idl
+    activaut.idl
+#   asynot.idl
+#   asysta.idl
+    bdaiface.idl
+#   binres.idl
+    bits.idl
+    bits1_5.idl
+#   cmdbas.idl
+#   cmdtxt.idl
+    comcat.idl
+    commoncontrols.idl
+    control.idl
+#   crtrow.idl
+    ctxtcall.idl
+#   dbccmd.idl
+#   dbcses.idl
+#   dbdsad.idl
+#   dbinit.idl
+#   dbprop.idl
+#   dbs.idl
+    devenum.idl
+    dimm.idl
+    dispex.idl
+    docobj.idl
+    downloadmgr.idl
+#   dyngraph.idl
+    exdisp.idl
+    fusion.idl
+    hlink.idl
+    htiframe.idl
+    iads.idl
+    icftypes.idl
+    imnact.idl
+    imnxport.idl
+    indexsrv.idl
+    mimeinfo.idl
+    mimeole.idl
+    mscoree.idl
+    msdadc.idl
+    mshtmhst.idl
+    msinkaut.idl
+    mstask.idl
+    msxml.idl
+    msxml2.idl
+    netcon.idl
+    netfw.idl
+    oaidl.idl
+    objidl.idl
+    objsafe.idl
+    ocidl.idl
+    ocmm.idl
+    oleacc.idl
+    oledb.idl
+    oleidl.idl
+#   opnrst.idl
+    optary.idl
+    perhist.idl
+    propidl.idl
+    propsys.idl
+    pstore.idl
+    richole.idl
+#   row.idl
+#   rowchg.idl
+#   rstbas.idl
+#   rstinf.idl
+#   rstloc.idl
+    sensevts.idl
+    servprov.idl
+#   sesprp.idl
+    shdeprecated.idl
+    shldisp.idl
+    shtypes.idl
+#   stdole2.idl
+    strmif.idl
+    structuredquerycondition.idl
+    textstor.idl
+    tom.idl
+    tuner.idl
+    unknwn.idl
+    urlhist.idl
+    urlmon.idl
+    vmr9.idl
+#   vmrender.idl
+    wbemcli.idl
+    wia_lh.idl
+    wia_xp.idl
+    wtypes.idl
+    xmldom.idl
+    xmldso.idl
+    xmllite.idl)
 
- FOREACH(_in_FILE ${ARGN})
+if(NOT MSVC)
+  LIST(APPEND SOURCE
+    activscp.idl
+    activdbg.idl
+    asptlb.idl
+    ctfutb.idl
+    mlang.idl
+    msctf.idl
+    mshtml.idl
+    shobjidl.idl
+    wincodec.idl
+    wuapi.idl
+)
+endif()
 
-   GET_FILENAME_COMPONENT(FILE ${_in_FILE} NAME_WE)
-
-   ADD_CUSTOM_COMMAND(
-     OUTPUT ${REACTOS_BINARY_DIR}/include/psdk/${FILE}.h
-     COMMAND native-widl -I${REACTOS_SOURCE_DIR}/include/dxsdk -I. -I${REACTOS_SOURCE_DIR}/include -I${REACTOS_SOURCE_DIR}/include/psdk -m32 --win32 -h -H ${REACTOS_BINARY_DIR}/include/psdk/${FILE}.h ${REACTOS_SOURCE_DIR}/include/psdk/${FILE}.idl
-     DEPENDS native-widl
-   )
-
-   SET_SOURCE_FILES_PROPERTIES(
-     ${REACTOS_BINARY_DIR}/include/psdk/${FILE}.h
-     PROPERTIES
-     GENERATED TRUE
-   )
-
-    LIST(APPEND PSDK_HEADERS ${REACTOS_BINARY_DIR}/include/psdk/${FILE}.h)  
-
- ENDFOREACH(_in_FILE ${ARGN})
-
-ENDMACRO (MACRO_ADD_PSDK_INTERFACES)
-
-file(GLOB_RECURSE SOURCE "*.idl")
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/access.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/asynot.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/asysta.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/binres.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/cmdbas.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/cmdtxt.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/crtrow.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/dbccmd.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/dbcses.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/dbdsad.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/dbinit.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/vmrender.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/sesprp.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/stdole2.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/rstloc.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/rstbas.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/rstinf.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/rowchg.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/row.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/opnrst.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/dyngraph.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/dbs.idl)
-LIST(REMOVE_ITEM SOURCE ${REACTOS_SOURCE_DIR}/include/psdk/dbprop.idl)
-
-MACRO_ADD_PSDK_INTERFACES(${SOURCE})
-
-ADD_CUSTOM_TARGET(psdk ALL DEPENDS ${PSDK_HEADERS})
+ADD_INTERFACE_DEFINITIONS(psdk ${SOURCE})
 
 ADD_CUSTOM_COMMAND(
   OUTPUT ${REACTOS_BINARY_DIR}/include/psdk/stdole2.tlb
@@ -60,4 +117,4 @@
 
 SET_SOURCE_FILES_PROPERTIES(${REACTOS_BINARY_DIR}/include/psdk/stdole2.tlb PROPERTIES GENERATED TRUE)
 
-ADD_CUSTOM_TARGET(stdole2 ALL DEPENDS ${REACTOS_BINARY_DIR}/include/psdk/stdole2.tlb)
+ADD_CUSTOM_TARGET(stdole2 ALL DEPENDS ${REACTOS_BINARY_DIR}/include/psdk/stdole2.tlb)

Modified: branches/cmake-bringup/toolchain-mingw32.cmake
URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/toolchain-mingw32.cmake?rev=48838&r1=48837&r2=48838&view=diff
==============================================================================
--- branches/cmake-bringup/toolchain-mingw32.cmake [iso-8859-1] (original)
+++ branches/cmake-bringup/toolchain-mingw32.cmake [iso-8859-1] Tue Sep 21 02:31:09 2010
@@ -26,7 +26,9 @@
 SET(CMAKE_RC_COMPILER ${MINGW_PREFIX}windres)
 SET(CMAKE_ASM_COMPILER ${MINGW_PREFIX}gcc)
 SET(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -x assembler-with-cpp -o <OBJECT> <FLAGS> <DEFINES> -D__ASM__ -c <SOURCE>")
+SET(CMAKE_IDL_COMPILER native-widl)
 
+SET(CMAKE_IDL_COMPILE_OBJECT "<CMAKE_IDL_COMPILER> <FLAGS> <DEFINES> -m32 --win32 -h -H <OBJECT> <SOURCE>")
 SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -i <SOURCE> <CMAKE_C_LINK_FLAGS> <DEFINES> -I${REACTOS_SOURCE_DIR}/include/psdk -I${REACTOS_BINARY_DIR}/include/psdk -I${REACTOS_SOURCE_DIR}/include/ -I${REACTOS_SOURCE_DIR}/include/reactos -I${REACTOS_BINARY_DIR}/include/reactos -I${REACTOS_SOURCE_DIR}/include/reactos/wine -I${REACTOS_SOURCE_DIR}/include/crt -I${REACTOS_SOURCE_DIR}/include/crt/mingw32 -O coff -o <OBJECT> ")
 
 # Use stdcall fixups, and don't link with anything by default unless we say so

Modified: branches/cmake-bringup/toolchain-msvc.cmake
URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/toolchain-msvc.cmake?rev=48838&r1=48837&r2=48838&view=diff
==============================================================================
--- branches/cmake-bringup/toolchain-msvc.cmake [iso-8859-1] (original)
+++ branches/cmake-bringup/toolchain-msvc.cmake [iso-8859-1] Tue Sep 21 02:31:09 2010
@@ -29,8 +29,10 @@
 set(CMAKE_CXX_COMPILER cl)
 SET(CMAKE_RC_COMPILER rc)
 SET(CMAKE_ASM_COMPILER ml)
+SET(CMAKE_IDL_COMPILER midl)
 
 SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <DEFINES> /I${REACTOS_SOURCE_DIR}/include/psdk /I${REACTOS_BINARY_DIR}/include/psdk /I${REACTOS_SOURCE_DIR}/include /I${REACTOS_SOURCE_DIR}/include/reactos /I${REACTOS_BINARY_DIR}/include/reactos /I${REACTOS_SOURCE_DIR}/include/reactos/wine /I${REACTOS_SOURCE_DIR}/include/crt /I${REACTOS_SOURCE_DIR}/include/crt/mingw32 /fo <OBJECT> <SOURCE>")
+SET(CMAKE_IDL_COMPILE_OBJECT "<CMAKE_IDL_COMPILER> <FLAGS> <DEFINES> /win32 /h <OBJECT> <SOURCE>")
 
 set(CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /W1 /Zm1000")
 set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi  /Ob0 /Od")




More information about the Ros-diffs mailing list