> For the complete documentation index, see [llms.txt](https://bo-yuan-huang.gitbook.io/ilang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bo-yuan-huang.gitbook.io/ilang/start/cmake.md).

# ILAng with CMake

## C++ project using CMake

To utilize ILAng in your C++ projects, you can look for the `ilang::ilang` interface target in your CMake recipe. This target manages and populates the required usage information such as include directories, linked libraries, compile features, etc. ILAng features (excluding features-in-development) are defined in the header file `ilang++.h`.&#x20;

```cpp
// cxx source
#include <ilang/ilang++.h>

void foo () {
    auto m = ilang::Ila("ila_name");
}
```

### External

With ILAng installed (out-of-source), you can locate the target directly with `find_package()` and use the imported target from the generated package configuration:

```c
# CMakeLists.txt
find_package(ilang REQUIRED)

add_library(MyProj ...)

target_link_libraries(MyProj PRIVATE ilang::ilang)
```

A template repo for starting a project using ILAng can be found in [PrincetonUniversity/template-ila](https://github.com/PrincetonUniversity/template-ila).

### Embedded

ILAng also supports embedded (in-source) build. To embed the library into an existing CMake project, place the entire source tree in a sub-directory and call `add_subdirectory()` in your CMake recipe:

```c
# CMakeLists.txt
add_subdirectory(ilang)

add_library(MyProj ...)

target_link_libraries(MyProj PRIVATE ilang::ilang)
```

### Supporting both

To allow your project to support either an externally installed or an embedded library at config time, you can use the following pattern:

```c
# top level CMakeLists.txt
project(MY_PROJ)

option(MY_PROJ_USE_EXTERNAL_ILANG "Use an external ILAng library" OFF)

add_subdirectory(externals)

add_library(MyPorj ...)

target_link_libraries(MyProj PRIVATE ilang::ilang)
```

And put the ILAng source (or sub-modules) in the sub-directory `externals/ilang`.

```c
# externals/CMakeLists.txt
if(MY_PROJ_USE_EXTERNAL_ILANG)
    find_package(ilang REQUIRED)
else()
    add_subdirectory(ilang)
endif()
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://bo-yuan-huang.gitbook.io/ilang/start/cmake.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
