https://github.com/apriorit/findidl
CMake module for building IDL files with MIDL and generating CLR DLL using Tlbimp
https://github.com/apriorit/findidl
cmake cmake-module com-interop com-object idl tlb tlbimp
Last synced: 11 months ago
JSON representation
CMake module for building IDL files with MIDL and generating CLR DLL using Tlbimp
- Host: GitHub
- URL: https://github.com/apriorit/findidl
- Owner: apriorit
- License: bsd-3-clause
- Created: 2018-08-15T14:20:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-02T16:16:35.000Z (over 1 year ago)
- Last Synced: 2025-01-18T21:31:51.437Z (about 1 year ago)
- Topics: cmake, cmake-module, com-interop, com-object, idl, tlb, tlbimp
- Language: CMake
- Homepage:
- Size: 32.2 KB
- Stars: 27
- Watchers: 7
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FindIDL [](https://ci.appveyor.com/project/apriorit/findidl)
CMake module for building IDL files with MIDL and generating CLR DLL using Tlbimp.
* [Introduction](#introduction)
* [Requirements](#requirements)
* [Usage](#usage)
* [find_package()](#find_package)
* [add_idl()](#add_idl)
* [add_idl() with tlbimp](#add_idl-with-tlbimp)
* [MIDL flags](#midl-flags)
* [TLBIMP flags](#tlbimp-flags)
* [Samples](#samples)
* [License](#license)
* [Version History](#version-history)
# 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
- [CMake 3.0](https://cmake.org/download/) or higher
- MIDL compiler
- Tlbimp.exe (optional)
# Usage
## find_package()
Add [FindIDL](https://github.com/apriorit/FindIDL) to the module search path and call `find_package`:
```cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake")
find_package(IDL REQUIRED)
```
[FindIDL](https://github.com/apriorit/FindIDL) will search for midl.exe and tlbimp.exe
## add_idl()
Takes two arguments: the name of the target project and idl file.
```cmake
add_idl( source)
```
Where:
- `` - name of the target project
- `source` - full path to idl file
Example:
```cmake
add_idl(GreeterIDL Greeter.idl)
```
The function does the same work as MIDL, specifically generates files:
- Greeter_i.h
- Greeter_i.c
- Greeter_p.c
- Greeter.tlb
To use the generated files the idl project should be linked as following
```cmake
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.
```cmake
add_idl( source TLBIMP )
```
Where:
- `` - name of the target project
- `source` - full path to idl file
- `TLBIMP` - flag to indicate to run tlbimp
- `` - name of the tlbimp target
Example:
```cmake
add_idl(GreeterIDLWithTLBIMP Greeter.idl TLBIMP GreeterInterop)
```
The function does the same work as MIDL and tlbimp.exe, specifically generates files:
- Greeter_i.h
- Greeter_i.c
- Greeter_p.c
- Greeter.tlb
- GreeterInterop.dll
To use the generated files the idl project should be linked as following
```cmake
target_link_libraries(MainCpp GreeterIDL)
```
Or if you want to use the file generated by tlbimp:
```cmake
target_link_libraries(MainCsharp GreeterInterop)
```
## MIDL flags
To specify additional command-line options for midl set `MIDL_FLAGS` variabe.
```cmake
set(MIDL_FLAGS /target NT60) # avoid MIDL2455 error
```
## TLBIMP flags
To specify additional command-line options for tlbimp set `TLBIMP_FLAGS` variabe.
```cmake
set(TLBIMP_FLAGS /silence:3002) # importing a type library into a platform agnostic assembly
```
# Samples
Take a look at the [samples](samples/) folder to see how to use [FindIDL](https://github.com/apriorit/FindIDL).
# License
[Apriorit](http://www.apriorit.com/) released [FindIDL](https://github.com/apriorit/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)
- New: Add `TLBIMP_FLAGS`
## Version 1.0.1 (08 Aug 2019)
- New: Add tlbimp
## Version 1.0.0 (26 Oct 2018)
- Initial public release