[COMCTL32] Install comctl32 v6 and its manifest in first stage
[reactos.git] / sdk / cmake / widl-support.cmake
1
2 #idl files support
3 if(ARCH STREQUAL "i386")
4 set(IDL_FLAGS -m32 --win32)
5 elseif(ARCH STREQUAL "amd64")
6 set(IDL_FLAGS -m64 --win64)
7 else()
8 set(IDL_FLAGS "")
9 endif()
10
11 function(add_typelib)
12 get_includes(INCLUDES)
13 get_defines(DEFINES)
14 foreach(FILE ${ARGN})
15 if(${FILE} STREQUAL "std_ole_v1.idl")
16 set(IDL_FLAGS ${IDL_FLAGS} --oldtlb)
17 endif()
18 get_filename_component(NAME ${FILE} NAME_WE)
19 add_custom_command(
20 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb
21 COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -t -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
22 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} native-widl)
23 list(APPEND OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb)
24 endforeach()
25 endfunction()
26
27 function(add_idl_headers TARGET)
28 get_includes(INCLUDES)
29 get_defines(DEFINES)
30 foreach(FILE ${ARGN})
31 get_filename_component(NAME ${FILE} NAME_WE)
32 set(HEADER ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h)
33 add_custom_command(
34 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h
35 COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
36 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} native-widl)
37 list(APPEND HEADERS ${HEADER})
38 endforeach()
39 add_custom_target(${TARGET} DEPENDS ${HEADERS})
40 endfunction()
41
42 function(add_rpcproxy_files)
43 get_includes(INCLUDES)
44 get_defines(DEFINES)
45
46 foreach(FILE ${ARGN})
47 get_filename_component(NAME ${FILE} NAME_WE)
48 list(APPEND IDLS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
49 add_custom_command(
50 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h
51 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}
52 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} native-widl)
53 endforeach()
54
55 # Extra pass to generate dlldata
56 add_custom_command(
57 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
58 COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} --dlldata-only -o ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${IDLS}
59 DEPENDS ${IDLS} native-widl)
60 endfunction()
61
62 function(add_rpc_files __type)
63 get_includes(INCLUDES)
64 get_defines(DEFINES)
65 # Is it a client or server module?
66 if(__type STREQUAL "server")
67 set(__server_client -Oif -s -o)
68 set(__suffix _s)
69 elseif(__type STREQUAL "client")
70 set(__server_client -Oif -c -o)
71 set(__suffix _c)
72 else()
73 message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files")
74 endif()
75 foreach(FILE ${ARGN})
76 get_filename_component(__name ${FILE} NAME_WE)
77 set(__name ${CMAKE_CURRENT_BINARY_DIR}/${__name}${__suffix})
78 if(NOT IS_ABSOLUTE ${FILE})
79 set(FILE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
80 endif()
81 add_custom_command(
82 OUTPUT ${__name}.c ${__name}.h
83 COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -H ${__name}.h ${__server_client} ${__name}.c ${FILE}
84 DEPENDS ${FILE} native-widl)
85 endforeach()
86 endfunction()
87
88 function(generate_idl_iids)
89 foreach(IDL_FILE ${ARGN})
90 get_filename_component(FILE ${IDL_FILE} NAME)
91 if(FILE STREQUAL "${IDL_FILE}")
92 set(IDL_FILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${IDL_FILE}")
93 else()
94 set(IDL_FILE_FULL ${IDL_FILE})
95 endif()
96 get_includes(INCLUDES)
97 get_defines(DEFINES)
98 get_filename_component(NAME ${IDL_FILE} NAME_WE)
99 add_custom_command(
100 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c
101 COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -u -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c ${IDL_FILE_FULL}
102 DEPENDS ${IDL_FILE_FULL} native-widl)
103 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c PROPERTIES GENERATED TRUE)
104 endforeach()
105 endfunction()
106
107 function(add_iid_library TARGET)
108 foreach(IDL_FILE ${ARGN})
109 get_filename_component(NAME ${IDL_FILE} NAME_WE)
110 generate_idl_iids(${IDL_FILE})
111 list(APPEND IID_SOURCES ${NAME}_i.c)
112 endforeach()
113 add_library(${TARGET} ${IID_SOURCES})
114 add_dependencies(${TARGET} psdk)
115 set_target_properties(${TARGET} PROPERTIES EXCLUDE_FROM_ALL TRUE)
116 endfunction()
117
118 function(add_idl_reg_script IDL_FILE)
119 get_filename_component(FILE ${IDL_FILE} NAME)
120 if(FILE STREQUAL "${IDL_FILE}")
121 set(IDL_FILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${IDL_FILE}")
122 else()
123 set(IDL_FILE_FULL ${IDL_FILE})
124 endif()
125 get_includes(INCLUDES)
126 get_defines(DEFINES)
127 get_filename_component(NAME ${IDL_FILE} NAME_WE)
128 add_custom_command(
129 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_r.res
130 COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -r -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_r.res ${IDL_FILE_FULL}
131 DEPENDS ${IDL_FILE_FULL} native-widl)
132 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${NAME}_r.res PROPERTIES
133 GENERATED TRUE EXTERNAL_OBJECT TRUE)
134 endfunction()