# How to compile linear assemble?

**URL:** https://discourse.cmake.org/t/how-to-compile-linear-assemble/8122
**Category:** Usage
**Tags:** comp:ti
**Created:** [May 13, 2023, 4:21pm UTC](https://discourse.cmake.org/t/how-to-compile-linear-assemble/8122 "2023-05-13T16:21:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Freed-Wu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/freed-wu/32/3347_2.png) [@Freed-Wu](https://discourse.cmake.org/u/Freed-Wu)
#### Post date: [May 13, 2023, 4:21pm UTC](https://discourse.cmake.org/t/how-to-compile-linear-assemble/8122/1 "2023-05-13T16:21:22Z")

</div>

`/usr/share/cmake/Modules/Compiler/TI-ASM.cmake`:

```cmake
include(Compiler/TI)
__compiler_ti(ASM)

set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS asm;s;abs)

```

However, TI has a special assemble named linear assemble:

```plaintext
$ cl6x --help
...
Default File Extensions Options:
  --ap_extension,-el=.ext Extension for linear asm files (default is .sa)
  --asm_extension,-ea=.ext Extension for assembly files (default is .asm)
  --c_extension,-ec=.ext Extension for C files (default is .c)
...

```

I try to `list(APPEND CMAKE_ASM_SOURCE_FILE_EXTENSIONS sa)`, but it still not work. `cmake --build build` will not compile `*.sa`.

code is [here](https://github.com/Freed-Wu/x264-dsp).

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 14, 2023, 12:27pm UTC](https://discourse.cmake.org/t/how-to-compile-linear-assemble/8122/2 "2023-05-14T12:27:23Z")

</div>

We can add to the extension list (there’s also a regex that does some filtering). However, manually setting the source file’s `LANGUAGE` property should override any such behaviors.

---

<div class="post-metadata">

### Author: ![Freed-Wu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/freed-wu/32/3347_2.png) [@Freed-Wu](https://discourse.cmake.org/u/Freed-Wu)
#### Post date: [May 15, 2023, 6:32am UTC](https://discourse.cmake.org/t/how-to-compile-linear-assemble/8122/3 "2023-05-15T06:32:36Z")

</div>

The problem is how to distinguish `*.asm` and `*.ap`? `*.asm` need `--asm_extension`, `*.ap` need `--ap_extension`. However, in `/usr/share/cmake/Modules/Compiler/TI.cmake`:

```cmake
set(__COMPILER_TI_SOURCE_FLAG_ASM "--asm_file")

```

---

<div class="post-metadata">

### Author: ![Freed-Wu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/freed-wu/32/3347_2.png) [@Freed-Wu](https://discourse.cmake.org/u/Freed-Wu)
#### Post date: [September 12, 2024, 1:41pm UTC](https://discourse.cmake.org/t/how-to-compile-linear-assemble/8122/4 "2024-09-12T13:41:22Z")

</div>

So how to solve this problem? Is it

Create a new language named such as AP:

```cmake
set(CMAKE_AP_SOURCE_FILE_EXTENSIONS sa)
set(__COMPILER_TI_SOURCE_FLAG_AP "--ap_file")

```

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [September 13, 2024, 1:00am UTC](https://discourse.cmake.org/t/how-to-compile-linear-assemble/8122/5 "2024-09-13T01:00:33Z")

</div>

I guess it should be added as assembler dialect. CMake has support for that (e.g. choosing NASM or MASM), which makes it easier than a complete new language.

Here’s a prototype [branch](https://gitlab.kitware.com/jtxa/cmake/-/commits/feature/ti-cl6x-asm-linear?ref_type=heads) you can try out.

If that work, I guess the next step would be to open an issue to discuss any details. e.g. I’m unsure how to name the dialect.
