Skip to content

Commit 8e253fb

Browse files
author
Your Name
committed
Add DSMIL toolchain preset and document wrappers
1 parent fb69d83 commit 8e253fb

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

dsmil/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ install(
3232
PROGRAMS ${DSMIL_WRAPPER_OUTPUTS}
3333
DESTINATION ${CMAKE_INSTALL_BINDIR}
3434
)
35+
36+
install(
37+
FILES cmake/dsmil-toolchain.cmake
38+
DESTINATION ${CMAKE_INSTALL_DATADIR}/dsmil
39+
)

dsmil/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ ninja -C build
126126
ninja -C build install
127127
```
128128

129+
### Using DSMIL wrappers and toolchain
130+
131+
- Wrappers: `dsmil-clang`, `dsmil-clang++`, and `dsmil-opt` are installed alongside the toolchain. They automatically load the DSMIL pass plugin, add DSMIL headers, and link the DSMIL runtime (`libdsmilrt.a`).
132+
- Toolchain file: A CMake preset is installed at `/usr/local/share/dsmil/dsmil-toolchain.cmake` (or `${CMAKE_INSTALL_PREFIX}/share/dsmil/` if you used a custom prefix). Use it so CMake picks up DSMIL by default:
133+
134+
```bash
135+
cmake -G Ninja -S <src> -B <build> \
136+
-DCMAKE_TOOLCHAIN_FILE=/usr/local/share/dsmil/dsmil-toolchain.cmake
137+
```
138+
139+
Set a custom prefix if you installed elsewhere:
140+
141+
```bash
142+
cmake ... -DDSMIL_PREFIX=/opt/dsllvm ...
143+
```
144+
129145
### Using DSLLVM
130146

131147
```bash

dsmil/cmake/dsmil-toolchain.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# DSMIL toolchain preset for consumers of an installed DSLLVM.
2+
#
3+
# Usage:
4+
# cmake -G Ninja -S <src> -B <build> \
5+
# -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/dsmil/dsmil-toolchain.cmake
6+
#
7+
# Customize the install prefix if DSLLVM was installed somewhere else:
8+
# cmake ... -DDSMIL_PREFIX=/opt/dsllvm ...
9+
10+
set(DSMIL_PREFIX "/usr/local" CACHE PATH "Install prefix of DSLLVM/DSMIL toolchain")
11+
12+
set(_DSMIL_BIN "${DSMIL_PREFIX}/bin")
13+
set(_DSMIL_LIB "${DSMIL_PREFIX}/lib")
14+
set(_DSMIL_INC "${DSMIL_PREFIX}/include/dsmil")
15+
16+
set(CMAKE_C_COMPILER "${_DSMIL_BIN}/dsmil-clang" CACHE FILEPATH "DSMIL C compiler" FORCE)
17+
set(CMAKE_CXX_COMPILER "${_DSMIL_BIN}/dsmil-clang++" CACHE FILEPATH "DSMIL C++ compiler" FORCE)
18+
19+
set(CMAKE_PREFIX_PATH "${DSMIL_PREFIX}" CACHE PATH "Search prefix for DSMIL libraries" FORCE)
20+
21+
# Ensure CMake can find the runtime and plugin from the install.
22+
set(CMAKE_LIBRARY_PATH "${_DSMIL_LIB}" CACHE PATH "DSMIL library path" FORCE)
23+
set(CMAKE_INCLUDE_PATH "${_DSMIL_INC}" CACHE PATH "DSMIL include path" FORCE)
24+
25+
if(NOT EXISTS "${CMAKE_C_COMPILER}")
26+
message(FATAL_ERROR "dsmil-clang not found at ${CMAKE_C_COMPILER}. Set DSMIL_PREFIX to your install.")
27+
endif()
28+
if(NOT EXISTS "${CMAKE_CXX_COMPILER}")
29+
message(FATAL_ERROR "dsmil-clang++ not found at ${CMAKE_CXX_COMPILER}. Set DSMIL_PREFIX to your install.")
30+
endif()

0 commit comments

Comments
 (0)