Home

Awesome

FindIDL Build status

CMake module for building IDL files with MIDL and generating CLR DLL using Tlbimp.

Introduction

IDL is used for creating COM servers. Unfortunately CMake has a limited support for IDL, so this module comes to rescue. The Type Library Importer (Tlbimp) converts the type definitions found within a COM type library (TLB) into equivalent definitions in a common language runtime assembly. The output of Tlbimp.exe is a binary file (an assembly) that contains runtime metadata for the types defined within the original type library.

Requirements

Usage

find_package()

Add FindIDL to the module search path and call find_package:

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake")
find_package(IDL REQUIRED)

FindIDL will search for midl.exe and tlbimp.exe

add_idl()

Takes two arguments: the name of the target project and idl file.

add_idl(<name> source)

Where:

Example:

add_idl(GreeterIDL Greeter.idl)

The function does the same work as MIDL, specifically generates files:

To use the generated files the idl project should be linked as following

target_link_libraries(Main GreeterIDL)

add_idl() with tlbimp

Takes four arguments: the name of the target project, idl file, TLBIMP flag and the name of the tlbimp target.

add_idl(<name> source TLBIMP <tlbimp name>)

Where:

Example:

add_idl(GreeterIDLWithTLBIMP Greeter.idl TLBIMP GreeterInterop)

The function does the same work as MIDL and tlbimp.exe, specifically generates files:

To use the generated files the idl project should be linked as following

target_link_libraries(MainCpp GreeterIDL)

Or if you want to use the file generated by tlbimp:

target_link_libraries(MainCsharp GreeterInterop)

MIDL flags

To specify additional command-line options for midl set MIDL_FLAGS variabe.

set(MIDL_FLAGS /target NT60) # avoid MIDL2455 error

TLBIMP flags

To specify additional command-line options for tlbimp set TLBIMP_FLAGS variabe.

set(TLBIMP_FLAGS /silence:3002) # importing a type library into a platform agnostic assembly

Samples

Take a look at the samples folder to see how to use FindIDL.

License

Apriorit released FindIDL under the OSI-approved 3-clause BSD license. You can freely use it in your commercial or opensource software.

Version History

Version 1.0.2 (15 Aug 2019)

Version 1.0.1 (08 Aug 2019)

Version 1.0.0 (26 Oct 2018)