Skip to content

Commit 60f052e

Browse files
authored
[CMake] Passthrough variables for packages to subbuilds (llvm#107611)
These packaged are imported by LLVMConfig.cmake and so we should be passing through the necessary variables from the parent build into the subbuilds. We use `CMAKE_CACHE_DEFAULT_ARGS` so subbuilds can override these variables if needed.
1 parent 5c8fd1e commit 60f052e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,32 @@ function(llvm_ExternalProject_Add name source_dir)
156156
set_target_properties(${name}-clear PROPERTIES FOLDER "${ARG_FOLDER}")
157157
endif ()
158158

159+
set(DEFAULT_PASSTHROUGH_VARIABLES
160+
LibEdit_INCLUDE_DIRS
161+
LibEdit_LIBRARIES
162+
ZLIB_INCLUDE_DIR
163+
ZLIB_LIBRARY
164+
zstd_INCLUDE_DIR
165+
zstd_LIBRARY
166+
LIBXML2_LIBRARY
167+
LIBXML2_INCLUDE_DIR
168+
CURL_INCLUDE_DIR
169+
CURL_LIBRARY
170+
HTTPLIB_INCLUDE_DIR
171+
HTTPLIB_HEADER_PATH
172+
Python3_EXECUTABLE
173+
Python3_LIBRARIES
174+
Python3_INCLUDE_DIRS
175+
Python3_RPATH
176+
)
177+
foreach(variable ${DEFAULT_PASSTHROUGH_VARIABLES})
178+
get_property(is_value_set CACHE ${variable} PROPERTY VALUE SET)
179+
if(${is_value_set})
180+
get_property(value CACHE ${variable} PROPERTY VALUE)
181+
list(APPEND CMAKE_CACHE_DEFAULT_ARGS "-D${variable}:STRING=${value}")
182+
endif()
183+
endforeach()
184+
159185
# Find all variables that start with a prefix and propagate them through
160186
get_cmake_property(variableNames VARIABLES)
161187

@@ -363,6 +389,7 @@ function(llvm_ExternalProject_Add name source_dir)
363389
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
364390
${cmake_args}
365391
${PASSTHROUGH_VARIABLES}
392+
CMAKE_CACHE_DEFAULT_ARGS ${CMAKE_CACHE_DEFAULT_ARGS}
366393
INSTALL_COMMAND ""
367394
STEP_TARGETS configure build
368395
BUILD_ALWAYS 1

0 commit comments

Comments
 (0)