diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1,5 +1,30 @@ # See docs/CMake.html for instructions about how to build LLVM with CMake. +# Generate a list of variables passed to cmake and save the list in +# the cache. This list could be used to figure out what should when +# building host tools for cross-compiles. +# TODO: We could compare the list to the previous run, issue +# diagnostics and save the new list, but not sure that's worthwhile. +if(NOT LLVM_CACHE_VARIABLES) + # Needed for IN_LIST below + if(POLICY CMP0057) + cmake_policy(SET CMP0057 NEW) + endif() + set(IGNORE_LIST CMAKE_COMMAND CMAKE_CPACK_COMMAND CMAKE_CTEST_COMMAND CMAKE_GENERATOR_PLATFORM CMAKE_GENERATOR_TOOLSET CMAKE_HOME_DIRECTORY CMAKE_ROOT) + message(STATUS "*** Gathering initial cache variables -- from command line and/or cache files into LLVM_CACHE_VARIABLES ***") + get_cmake_property(vars CACHE_VARIABLES) + foreach(var ${vars}) + if(var IN_LIST IGNORE_LIST) + continue() + endif() + list(APPEND LLVM_CACHE_VARIABLES ${var}) + endforeach() + set(LLVM_CACHE_VARIABLES ${LLVM_CACHE_VARIABLES} CACHE STRING "List of variables passed to cmake on the commandline or in cache files." FORCE) + foreach(var ${LLVM_CACHE_VARIABLES}) + message(STATUS "from commandline or cache files: ${var} = ${${var}}") + endforeach() +endif() + cmake_minimum_required(VERSION 3.4.3) if(POLICY CMP0068)