1 2#idl files support 3if(ARCH STREQUAL "i386") 4 set(IDL_FLAGS /nologo /win32 /no_def_idir) 5elseif(ARCH STREQUAL "amd64") 6 set(IDL_FLAGS /nologo /amd64 /no_def_idir) 7else() 8 set(IDL_FLAGS /nologo /no_def_idir) 9endif() 10 11function(add_typelib) 12 get_includes(_includes) 13 get_defines(_defines) 14 foreach(_idl_file ${ARGN}) 15 get_filename_component(_name_we ${_idl_file} NAME_WE) 16 add_custom_command( 17 OUTPUT ${_name_we}.tlb 18 COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /tlb ${_name_we}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file} 19 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}) 20 endforeach() 21endfunction() 22 23function(add_idl_headers TARGET) 24 get_includes(_includes) 25 get_defines(_defines) 26 foreach(_idl_file ${ARGN}) 27 get_filename_component(_name_we ${_idl_file} NAME_WE) 28 add_custom_command( 29 OUTPUT ${_name_we}.h 30 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} 31 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}) 32 list(APPEND _target_dependencies ${_name_we}.h) 33 endforeach() 34 add_custom_target(${TARGET} DEPENDS ${_target_dependencies}) 35endfunction() 36 37function(add_rpcproxy_files) 38 get_includes(_includes) 39 get_defines(_defines) 40 set(_chain_dependency "") 41 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES GENERATED TRUE) 42 foreach(_idl_file ${ARGN}) 43 get_filename_component(_name_we ${_idl_file} NAME_WE) 44 add_custom_command( 45 OUTPUT ${_name_we}_p.c ${_name_we}_p.h 46 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} 47 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file} ${_chain_dependency}) 48 list(APPEND _chain_dependency ${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_p.c) 49 list(APPEND _chain_dependency ${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_p.h) 50 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}) 51 endforeach() 52endfunction() 53 54function(add_rpc_files _type) 55 get_includes(_includes) 56 get_defines(_defines) 57 # Is it a client or server module? 58 if(_type STREQUAL "server") 59 set(_server_client /sstub) 60 set(_suffix _s) 61 set(_prevent_second_type /client none) 62 elseif(_type STREQUAL "client") 63 set(_server_client /cstub) 64 set(_suffix _c) 65 set(_prevent_second_type /server none) 66 else() 67 message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files") 68 endif() 69 foreach(_idl_file ${ARGN}) 70 if(NOT IS_ABSOLUTE ${_idl_file}) 71 set(_idl_file ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}) 72 endif() 73 get_filename_component(_name_we ${_idl_file} NAME_WE) 74 set(_name_we ${_name_we}${_suffix}) 75 add_custom_command( 76 OUTPUT ${_name_we}.c ${_name_we}.h 77 COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} /h ${_name_we}.h ${_server_client} ${_name_we}.c ${_prevent_second_type} ${_idl_file} 78 DEPENDS ${_idl_file}) 79 endforeach() 80endfunction() 81 82function(generate_idl_iids) 83 foreach(_idl_file ${ARGN}) 84 get_includes(_includes) 85 get_defines(_defines) 86 if(NOT IS_ABSOLUTE ${_idl_file}) 87 set(_idl_file "${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file}") 88 endif() 89 get_filename_component(_name_we ${_idl_file} NAME_WE) 90 add_custom_command( 91 OUTPUT ${_name_we}_i.c ${_name_we}_i.h 92 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} 93 DEPENDS ${_idl_file}) 94 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_i.c PROPERTIES GENERATED TRUE) 95 endforeach() 96endfunction() 97 98function(add_iid_library _target) 99 foreach(_idl_file ${ARGN}) 100 generate_idl_iids(${_idl_file}) 101 get_filename_component(_name_we ${_idl_file} NAME_WE) 102 list(APPEND _iid_sources ${CMAKE_CURRENT_BINARY_DIR}/${_name_we}_i.c) 103 endforeach() 104 add_library(${_target} ${_iid_sources}) 105 106 # for wtypes.h 107 add_dependencies(${_target} psdk) 108 109 set_target_properties(${_target} PROPERTIES EXCLUDE_FROM_ALL TRUE) 110endfunction() 111