Skip to content

Change CMake files to library target - #1579

Closed
SlyEcho wants to merge 1 commit into
masterfrom
cmake-change
Closed

SlyEcho wants to merge 1 commit into
masterfrom
cmake-change

Conversation

@SlyEcho

@SlyEcho SlyEcho commented May 23, 2023 •

Copy link
Copy Markdown
Contributor

The main change here is to get rid of the file and library lists and use targets instead.

Here is an example of the dependencies of main.cpp when building with LLAMA_CLBLAST=ON:

LLAMA_CUBLAS=ON:

compile_commands.json for CUDA build
[
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/cc -DGGML_USE_CUBLAS -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -mf16c -mfma -mavx -mavx2 -o CMakeFiles/ggml.dir/ggml.c.o -c /home/henri/src/llama.cpp/ggml.c",
  "file": "/home/henri/src/llama.cpp/ggml.c",
  "output": "CMakeFiles/ggml.dir/ggml.c.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -DGGML_USE_CUBLAS -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o CMakeFiles/llama.dir/llama.cpp.o -c /home/henri/src/llama.cpp/llama.cpp",
  "file": "/home/henri/src/llama.cpp/llama.cpp",
  "output": "CMakeFiles/llama.dir/llama.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/opt/cuda/bin/nvcc -forward-unknown-to-host-compiler -DGGML_USE_CUBLAS -isystem /opt/cuda/include -O3 -DNDEBUG -std=c++11 -mf16c -mfma -mavx -mavx2 -x cu -c /home/henri/src/llama.cpp/ggml-cuda.cu -o CMakeFiles/ggml-cuda.dir/ggml-cuda.cu.o",
  "file": "/home/henri/src/llama.cpp/ggml-cuda.cu",
  "output": "CMakeFiles/ggml-cuda.dir/ggml-cuda.cu.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o tests/CMakeFiles/test-quantize-fns.dir/test-quantize-fns.cpp.o -c /home/henri/src/llama.cpp/tests/test-quantize-fns.cpp",
  "file": "/home/henri/src/llama.cpp/tests/test-quantize-fns.cpp",
  "output": "tests/CMakeFiles/test-quantize-fns.dir/test-quantize-fns.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o tests/CMakeFiles/test-quantize-perf.dir/test-quantize-perf.cpp.o -c /home/henri/src/llama.cpp/tests/test-quantize-perf.cpp",
  "file": "/home/henri/src/llama.cpp/tests/test-quantize-perf.cpp",
  "output": "tests/CMakeFiles/test-quantize-perf.dir/test-quantize-perf.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o tests/CMakeFiles/test-sampling.dir/test-sampling.cpp.o -c /home/henri/src/llama.cpp/tests/test-sampling.cpp",
  "file": "/home/henri/src/llama.cpp/tests/test-sampling.cpp",
  "output": "tests/CMakeFiles/test-sampling.dir/test-sampling.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o tests/CMakeFiles/test-tokenizer-0.dir/test-tokenizer-0.cpp.o -c /home/henri/src/llama.cpp/tests/test-tokenizer-0.cpp",
  "file": "/home/henri/src/llama.cpp/tests/test-tokenizer-0.cpp",
  "output": "tests/CMakeFiles/test-tokenizer-0.dir/test-tokenizer-0.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/CMakeFiles/common.dir/common.cpp.o -c /home/henri/src/llama.cpp/examples/common.cpp",
  "file": "/home/henri/src/llama.cpp/examples/common.cpp",
  "output": "examples/CMakeFiles/common.dir/common.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/main/CMakeFiles/main.dir/main.cpp.o -c /home/henri/src/llama.cpp/examples/main/main.cpp",
  "file": "/home/henri/src/llama.cpp/examples/main/main.cpp",
  "output": "examples/main/CMakeFiles/main.dir/main.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/quantize/CMakeFiles/quantize.dir/quantize.cpp.o -c /home/henri/src/llama.cpp/examples/quantize/quantize.cpp",
  "file": "/home/henri/src/llama.cpp/examples/quantize/quantize.cpp",
  "output": "examples/quantize/CMakeFiles/quantize.dir/quantize.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/quantize-stats/CMakeFiles/quantize-stats.dir/quantize-stats.cpp.o -c /home/henri/src/llama.cpp/examples/quantize-stats/quantize-stats.cpp",
  "file": "/home/henri/src/llama.cpp/examples/quantize-stats/quantize-stats.cpp",
  "output": "examples/quantize-stats/CMakeFiles/quantize-stats.dir/quantize-stats.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/perplexity/CMakeFiles/perplexity.dir/perplexity.cpp.o -c /home/henri/src/llama.cpp/examples/perplexity/perplexity.cpp",
  "file": "/home/henri/src/llama.cpp/examples/perplexity/perplexity.cpp",
  "output": "examples/perplexity/CMakeFiles/perplexity.dir/perplexity.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/embedding/CMakeFiles/embedding.dir/embedding.cpp.o -c /home/henri/src/llama.cpp/examples/embedding/embedding.cpp",
  "file": "/home/henri/src/llama.cpp/examples/embedding/embedding.cpp",
  "output": "examples/embedding/CMakeFiles/embedding.dir/embedding.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/save-load-state/CMakeFiles/save-load-state.dir/save-load-state.cpp.o -c /home/henri/src/llama.cpp/examples/save-load-state/save-load-state.cpp",
  "file": "/home/henri/src/llama.cpp/examples/save-load-state/save-load-state.cpp",
  "output": "examples/save-load-state/CMakeFiles/save-load-state.dir/save-load-state.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/benchmark/CMakeFiles/benchmark.dir/benchmark-matmult.cpp.o -c /home/henri/src/llama.cpp/examples/benchmark/benchmark-matmult.cpp",
  "file": "/home/henri/src/llama.cpp/examples/benchmark/benchmark-matmult.cpp",
  "output": "examples/benchmark/CMakeFiles/benchmark.dir/benchmark-matmult.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/examples -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o examples/baby-llama/CMakeFiles/baby-llama.dir/baby-llama.cpp.o -c /home/henri/src/llama.cpp/examples/baby-llama/baby-llama.cpp",
  "file": "/home/henri/src/llama.cpp/examples/baby-llama/baby-llama.cpp",
  "output": "examples/baby-llama/CMakeFiles/baby-llama.dir/baby-llama.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/pocs -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o pocs/vdot/CMakeFiles/vdot.dir/vdot.cpp.o -c /home/henri/src/llama.cpp/pocs/vdot/vdot.cpp",
  "file": "/home/henri/src/llama.cpp/pocs/vdot/vdot.cpp",
  "output": "pocs/vdot/CMakeFiles/vdot.dir/vdot.cpp.o"
},
{
  "directory": "/home/henri/src/llama.cpp/build-cuda",
  "command": "/usr/bin/c++ -I/home/henri/src/llama.cpp/pocs -I/home/henri/src/llama.cpp/examples/. -I/home/henri/src/llama.cpp/. -O3 -DNDEBUG -std=gnu++11 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -mf16c -mfma -mavx -mavx2 -o pocs/vdot/CMakeFiles/q8dot.dir/q8dot.cpp.o -c /home/henri/src/llama.cpp/pocs/vdot/q8dot.cpp",
  "file": "/home/henri/src/llama.cpp/pocs/vdot/q8dot.cpp",
  "output": "pocs/vdot/CMakeFiles/q8dot.dir/q8dot.cpp.o"
}
]

The main change here is to get rid of the
file and library lists and use targets instead.
slaren
slaren previously approved these changes May 23, 2023

@slaren slaren left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better than the GGML_CUDA_SOURCES hack.

@slaren
slaren dismissed their stale review May 23, 2023 23:46

Let's fix the failing builds first though.

@SlyEcho

SlyEcho commented May 24, 2023

Copy link
Copy Markdown
Contributor Author

Let's fix the failing builds first though.

Yeah, I saw them, I will test it again now that I'm on Windows.

@SlyEcho
SlyEcho requested a review from Green-Sky May 24, 2023 08:06
@Green-Sky

Copy link
Copy Markdown
Collaborator

Can you resolve and re-run ci?
why did you switch from OBJECT to STATIC?
Looks look otherwise :)

@SlyEcho

SlyEcho commented May 27, 2023

Copy link
Copy Markdown
Contributor Author

I will deal with the other stuff first and get back to this. I want to test on Windows and Mac as well.

why did you switch from OBJECT to STATIC?

Because object libraries cannot propagate dependencies. I don't see any downsides to static libs otherwise, unless that was the Windows problem.

@SlyEcho SlyEcho closed this Aug 29, 2023
@SlyEcho
SlyEcho deleted the cmake-change branch August 29, 2023 16:58
@SlyEcho

SlyEcho commented Aug 29, 2023

Copy link
Copy Markdown
Contributor Author

Have to come back later, code is diverged a lot now. I meant to do this PR before the ROCm merge because I use some of these ideas there, but it went in already and it's not that crucial.

phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
* Little maintenance

* llama-quantize : Add the missing items in the help

* Add GGML_MAX_CONTEXTS define in the general cmakelist.txt

* Make the KV cache (CPU) based warnings clearer

* Correct placement of GGML_MAX_CONTEXTS definition

* Revert wrong indents

This reverts commit d0728cbb6c6d4d6d8dc13f062e542d232647a38d.

* Moving the GGML_MAX_CONTEXTS definition to src/CMakeLists.txt

* Update warning message for unsupported KV cache types

* forgotten antislash
ggerganov added a commit that referenced this pull request Aug 21, 2026
As agreed in ggml discussion #1579, the official semver releases now
include a nightly-tag.txt asset containing the tag of the corresponding
nightly release (e.g. b10485). The Web UI assets are published to the
HF bucket under the nightly tag, so this makes them discoverable for
each official release.

- make-release-desc.sh: expose the resolved nightly tag as a
  nightly_tag output
- make-release.yml: create nightly-tag.txt from that tag, upload it
  as a release asset (skipped on dry-run), mention it in the release
  body and in the dry-run summary

Assisted-by: pi:llama.cpp/Qwen3.8-27B
therealkenc pushed a commit to therealkenc/llama.cpp that referenced this pull request Aug 24, 2026
As agreed in ggml discussion ggml-org#1579, the official semver releases now
include a nightly-tag.txt asset containing the tag of the corresponding
nightly release (e.g. b10485). The Web UI assets are published to the
HF bucket under the nightly tag, so this makes them discoverable for
each official release.

- make-release-desc.sh: expose the resolved nightly tag as a
  nightly_tag output
- make-release.yml: create nightly-tag.txt from that tag, upload it
  as a release asset (skipped on dry-run), mention it in the release
  body and in the dry-run summary

Assisted-by: pi:llama.cpp/Qwen3.8-27B
thecodacus pushed a commit to thecodacus/llama.cpp that referenced this pull request Sep 7, 2026
As agreed in ggml discussion ggml-org#1579, the official semver releases now
include a nightly-tag.txt asset containing the tag of the corresponding
nightly release (e.g. b10485). The Web UI assets are published to the
HF bucket under the nightly tag, so this makes them discoverable for
each official release.

- make-release-desc.sh: expose the resolved nightly tag as a
  nightly_tag output
- make-release.yml: create nightly-tag.txt from that tag, upload it
  as a release asset (skipped on dry-run), mention it in the release
  body and in the dry-run summary

Assisted-by: pi:llama.cpp/Qwen3.8-27B
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
As agreed in ggml discussion ggml-org#1579, the official semver releases now
include a nightly-tag.txt asset containing the tag of the corresponding
nightly release (e.g. b10485). The Web UI assets are published to the
HF bucket under the nightly tag, so this makes them discoverable for
each official release.

- make-release-desc.sh: expose the resolved nightly tag as a
  nightly_tag output
- make-release.yml: create nightly-tag.txt from that tag, upload it
  as a release asset (skipped on dry-run), mention it in the release
  body and in the dry-run summary

Assisted-by: pi:llama.cpp/Qwen3.8-27B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants