-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
75 lines (64 loc) · 3.27 KB
/
CMakeLists.txt
File metadata and controls
75 lines (64 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
cmake_minimum_required(VERSION 3.16)
project(ltx.cpp VERSION 0.1.0 LANGUAGES CXX C)
include(CheckCXXCompilerFlag)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
# Backend options: build command determines target (same pattern as acestep.cpp).
# Defaults: Metal ON on Apple, others OFF — override with -DLTX_*=ON as needed.
if(APPLE)
set(LTX_METAL_DEFAULT ON)
else()
set(LTX_METAL_DEFAULT OFF)
endif()
option(LTX_CUDA "Enable CUDA backend (Linux/Windows)" OFF)
option(LTX_VULKAN "Enable Vulkan backend" OFF)
option(LTX_METAL "Enable Metal backend (Apple MPS)" ${LTX_METAL_DEFAULT})
option(LTX_HIP "Enable ROCm/HIP backend (Linux AMD)" OFF)
# ── GGML submodule ──────────────────────────────────────────────────────────
if(LTX_CUDA)
set(GGML_CUDA ON CACHE BOOL "" FORCE)
endif()
if(LTX_VULKAN)
set(GGML_VULKAN ON CACHE BOOL "" FORCE)
endif()
if(LTX_METAL)
set(GGML_METAL ON CACHE BOOL "" FORCE)
endif()
if(LTX_HIP)
set(GGML_HIP ON CACHE BOOL "" FORCE)
endif()
add_subdirectory(ggml)
# LTX/DiT GGUF tensor names can exceed 64 chars; allow up to 256 (must match ggml struct).
if(NOT DEFINED GGML_MAX_NAME)
set(GGML_MAX_NAME 256 CACHE STRING "ggml: max tensor name length (LTX DiT needs > 64)")
endif()
target_compile_definitions(ggml-base PRIVATE GGML_MAX_NAME=${GGML_MAX_NAME})
# ── Common interface library ─────────────────────────────────────────────────
add_library(ltx_common INTERFACE)
target_include_directories(ltx_common INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/ggml/include
)
target_compile_definitions(ltx_common INTERFACE GGML_MAX_NAME=${GGML_MAX_NAME})
target_link_libraries(ltx_common INTERFACE ggml)
# ── ltx-generate binary ──────────────────────────────────────────────────────
add_executable(ltx-generate src/ltx-generate.cpp src/safetensors_loader.cpp)
target_link_libraries(ltx-generate PRIVATE ltx_common)
if(MSVC)
target_compile_options(ltx-generate PRIVATE /W3)
else()
# -Wno-unused-but-set-variable suppresses warnings from vendored stb_image.h.
# The flag is supported by GCC and Apple Clang 13+; guard it so older
# toolchains don't fail with an "unrecognized option" error.
check_cxx_compiler_flag(-Wno-unused-but-set-variable HAS_WNO_UNUSED_BUT_SET_VARIABLE)
set(_ltx_generate_warn_flags -Wall -Wextra -Wno-unused-parameter)
if(HAS_WNO_UNUSED_BUT_SET_VARIABLE)
list(APPEND _ltx_generate_warn_flags -Wno-unused-but-set-variable)
endif()
target_compile_options(ltx-generate PRIVATE ${_ltx_generate_warn_flags})
endif()
# ── quantize utility ─────────────────────────────────────────────────────────
add_executable(ltx-quantize src/ltx-quantize.cpp)
target_link_libraries(ltx-quantize PRIVATE ltx_common)
install(TARGETS ltx-generate ltx-quantize RUNTIME DESTINATION bin)