# 256 character limit on CACHE INTERNAL entries

**URL:** https://discourse.cmake.org/t/256-character-limit-on-cache-internal-entries/9350
**Category:** Usage
**Created:** [November 2, 2023, 9:36pm UTC](https://discourse.cmake.org/t/256-character-limit-on-cache-internal-entries/9350 "2023-11-02T21:36:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![EosPengwern](https://discourse.cmake.org/user_avatar/discourse.cmake.org/eospengwern/32/3904_2.png) [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)
#### Post date: [November 2, 2023, 9:36pm UTC](https://discourse.cmake.org/t/256-character-limit-on-cache-internal-entries/9350/1 "2023-11-02T21:36:32Z")

</div>

This is a comment rather than a question…

I had a problem today where I was trying to store a long list of libraries, which were being found in a recursive search through many layers of function calls but needed to be available in the global scope.

I decided it would a clever idea to store the list globally as a string using CACHE INTERNAL.

It wasn’t clever; after a certain number of libraries had been found, the rest were being ignored. It was a hard problem to debug, but eventually I realised that once the total length of the string exceeded 256 characters, nothing more could be added to it.

I wouldn’t mind so much but I can’t find this in the documentation anywhere.

I got my application working by replacing the intended cache variable with an ordinary list, and making sure that it was promoted using PARENT\_SCOPE in each layer of the the recursion all the way up to the global scope. It does the job, but it’s a much less elegant solution than I’d hoped for.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [November 2, 2023, 9:51pm UTC](https://discourse.cmake.org/t/256-character-limit-on-cache-internal-entries/9350/2 "2023-11-02T21:51:25Z")

</div>

That’s surprising to me. I’ve stored very long contents in ordinary CMake variables, and I’m not aware of any restriction specific to cache variables. Can you provide a minimal example which demonstrates the problem for you? If you can distill it down to the bare minimum needed to show the problem, that will make it more likely someone will investigate. I suspect the real problem you’re hitting is related to the different variable scopes involved (each function has its own variable scope).

---

<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: [November 2, 2023, 10:03pm UTC](https://discourse.cmake.org/t/256-character-limit-on-cache-internal-entries/9350/3 "2023-11-02T22:03:59Z")

</div>

I can’t reproduce this:

```cmake
cmake_minimum_required(VERSION 3.12)
project(foo NONE)

set(value
  12345678901234567890123456789012345678901234567890
  12345678901234567890123456789012345678901234567890
  12345678901234567890123456789012345678901234567890
  12345678901234567890123456789012345678901234567890
  12345678901234567890123456789012345678901234567890
  12345678901234567890123456789012345678901234567890
  12345678901234567890123456789012345678901234567890
  12345678901234567890123456789012345678901234567890)
message("${long}")
set(long "${value}" CACHE INTERNAL "")
message("${value}")
message("${long}")

```

```plaintext
$ cmake .

12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/boeckb/misc/code/sb/cm-cache-int-limit
$ cmake .
12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890;12345678901234567890123456789012345678901234567890
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/boeckb/misc/code/sb/cm-cache-int-limit

```

In any case, I would recommend using a global property instead of a cache variable, especially if it only matters within a single configure run (and not across configures).
