[llvm] [CMake] Passthrough variables for packages to subbuilds (PR #107611)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 09:33:47 PDT 2024


================
@@ -156,6 +156,32 @@ function(llvm_ExternalProject_Add name source_dir)
     set_target_properties(${name}-clear PROPERTIES FOLDER "${ARG_FOLDER}")
   endif ()
 
+  set(DEFAULT_PASSTHROUGH_VARIABLES
+    LibEdit_INCLUDE_DIRS
+    LibEdit_LIBRARIES
+    ZLIB_INCLUDE_DIR
+    ZLIB_LIBRARY
+    zstd_INCLUDE_DIR
+    zstd_LIBRARY
+    LIBXML2_LIBRARY
+    LIBXML2_INCLUDE_DIR
+    CURL_INCLUDE_DIR
+    CURL_LIBRARY
+    HTTPLIB_INCLUDE_DIR
+    HTTPLIB_HEADER_PATH
+    Python3_EXECUTABLE
+    Python3_LIBRARIES
+    Python3_INCLUDE_DIRS
+    Python3_RPATH
+    )
+  foreach(variable ${DEFAULT_PASSTHROUGH_VARIABLES})
+    get_property(is_value_set CACHE ${variable} PROPERTY VALUE SET)
+    if(${is_value_set})
+      get_property(value CACHE ${variable} PROPERTY VALUE)
+      list(APPEND CMAKE_CACHE_DEFAULT_ARGS "-D${variable}:STRING=${value}")
----------------
petrhosek wrote:

That's what I read as well but I wasn't sure if it's needed or not so I tested and it looks like it's not required.

The following example:
```cmake
ExternalProject_Add(test
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test
  CMAKE_ARGS -Done=a|b|c
  CMAKE_CACHE_ARGS -Dtwo:STRING=a;b;c
  CMAKE_CACHE_DEFAULT_ARGS -Dthree:STRING=a|b|c
  LIST_SEPARATOR |
)
```
produces the following cache file:
```cmake
set(two "a;b;c" CACHE STRING "Initial cache" FORCE)
set(three "a;b;c" CACHE STRING "Initial cache" )
```

https://github.com/llvm/llvm-project/pull/107611


More information about the llvm-commits mailing list