mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-27 03:43:36 +00:00
[CMAKE] Add add_rpc_file macro
The add_rpc_file macro enables us to use ACF files or set prefixes.
This commit is contained in:
@@ -79,6 +79,46 @@ function(add_rpc_files _type)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(add_rpc_file _type _idl_file)
|
||||
cmake_parse_arguments(__args "" "ACF;PREFIX_ALL;PREFIX_CLIENT;PREFIX_SERVER" "" ${ARGN})
|
||||
get_includes(_includes)
|
||||
get_defines(_defines)
|
||||
# Is it a client or server module?
|
||||
if(_type STREQUAL "server")
|
||||
set(_server_client /sstub)
|
||||
set(_suffix _s)
|
||||
set(_prevent_second_type /client none)
|
||||
elseif(_type STREQUAL "client")
|
||||
set(_server_client /cstub)
|
||||
set(_suffix _c)
|
||||
set(_prevent_second_type /server none)
|
||||
else()
|
||||
message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files")
|
||||
endif()
|
||||
if(__args_ACF)
|
||||
set(__additional_flags ${__additional_flags} /acf=${__args_ACF})
|
||||
endif()
|
||||
if (__args_PREFIX_ALL)
|
||||
set(__additional_flags ${__additional_flags} /prefix-all=${__args_PREFIX_ALL})
|
||||
else()
|
||||
if (__args_PREFIX_CLIENT)
|
||||
set(__additional_flags ${__additional_flags} /prefix-client=${__args_PREFIX_CLIENT})
|
||||
endif()
|
||||
if (__args_PREFIX_SERVER)
|
||||
set(__additional_flags ${__additional_flags} /prefix-server=${__args_PREFIX_SERVER})
|
||||
endif()
|
||||
endif()
|
||||
if(NOT IS_ABSOLUTE ${_idl_file})
|
||||
set(_idl_file ${CMAKE_CURRENT_SOURCE_DIR}/${_idl_file})
|
||||
endif()
|
||||
get_filename_component(_name_we ${_idl_file} NAME_WE)
|
||||
set(_name_we ${_name_we}${_suffix})
|
||||
add_custom_command(
|
||||
OUTPUT ${_name_we}.c ${_name_we}.h
|
||||
COMMAND midl ${_includes} ${_defines} ${IDL_FLAGS} ${_additional_flags} /h ${_name_we}.h ${_server_client} ${_name_we}.c ${_prevent_second_type} ${_idl_file}
|
||||
DEPENDS ${_idl_file})
|
||||
endfunction()
|
||||
|
||||
function(generate_idl_iids)
|
||||
foreach(_idl_file ${ARGN})
|
||||
get_includes(_includes)
|
||||
|
||||
@@ -103,6 +103,45 @@ function(add_rpc_files __type)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(add_rpc_file __type __idl_file)
|
||||
cmake_parse_arguments(__args "" "ACF;PREFIX_ALL;PREFIX_CLIENT;PREFIX_SERVER" "" ${ARGN})
|
||||
get_includes(INCLUDES)
|
||||
get_defines(DEFINES)
|
||||
set(__additional_flags -Oif)
|
||||
# Is it a client or server module?
|
||||
if(__type STREQUAL "server")
|
||||
set(__server_client -s)
|
||||
set(__suffix _s)
|
||||
elseif(__type STREQUAL "client")
|
||||
set(__server_client -c)
|
||||
set(__suffix _c)
|
||||
else()
|
||||
message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files")
|
||||
endif()
|
||||
if(__args_ACF)
|
||||
set(__additional_flags ${__additional_flags} --acf=${__args_ACF})
|
||||
endif()
|
||||
if (__args_PREFIX_ALL)
|
||||
set(__additional_flags ${__additional_flags} --prefix-all=${__args_PREFIX_ALL})
|
||||
else()
|
||||
if (__args_PREFIX_CLIENT)
|
||||
set(__additional_flags ${__additional_flags} --prefix-client=${__args_PREFIX_CLIENT})
|
||||
endif()
|
||||
if (__args_PREFIX_SERVER)
|
||||
set(__additional_flags ${__additional_flags} --prefix-server=${__args_PREFIX_SERVER})
|
||||
endif()
|
||||
endif()
|
||||
get_filename_component(__name ${__idl_file} NAME_WE)
|
||||
set(__name ${__name}${__suffix})
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${__name}.c ${CMAKE_CURRENT_BINARY_DIR}/${__name}.h
|
||||
# We generate the two files in two passes because WIDL accepts only one custom file name as output
|
||||
COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${__additional_flags} ${__server_client} -o ${CMAKE_CURRENT_BINARY_DIR}/${__name}.c -H ${__name}.h ${__idl_file}
|
||||
COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${__additional_flags} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${__name}.h ${__idl_file}
|
||||
DEPENDS ${__idl_file} native-widl
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endfunction()
|
||||
|
||||
function(generate_idl_iids)
|
||||
foreach(IDL_FILE ${ARGN})
|
||||
get_includes(INCLUDES)
|
||||
|
||||
Reference in New Issue
Block a user