-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Make some optimizations to the CMake build system #161981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Example usage | ||
# llvm_get_cache_vars(before) | ||
# include(SomeModule) | ||
# llvm_diff_cache_vars("${before}" new_vars new_pairs) | ||
|
||
# message(STATUS "New cache variables: ${new_vars}") | ||
# message(STATUS "New cache vars and values:\n${new_pairs}") | ||
|
||
# get_list_of_existing_cache_variables(existing) | ||
function(llvm_get_list_of_existing_cache_variables out_var) | ||
get_cmake_property(_all CACHE_VARIABLES) | ||
if(NOT _all) | ||
set(_all "") | ||
endif() | ||
set(${out_var} "${_all}" PARENT_SCOPE) | ||
endfunction() | ||
|
||
# list_of_new_cache_variables_and_values(existing new_vars_and_values) | ||
# - `existing` is the name of the var returned by the first helper | ||
# - `new_vars_and_values` will be a list like: NAME=VALUE (TYPE=...);NAME2=VALUE2 (TYPE=...) | ||
function(llvm_list_of_new_cache_variables_and_values existing_list_var out_var) | ||
# Existing (pre-include) snapshot | ||
set(_before "${${existing_list_var}}") | ||
|
||
# Current (post-include) snapshot | ||
get_cmake_property(_after CACHE_VARIABLES) | ||
|
||
# Compute new names | ||
set(_new "${_after}") | ||
if(_before) | ||
list(REMOVE_ITEM _new ${_before}) | ||
endif() | ||
|
||
# Pack "NAME=VALUE (TYPE=...)" for each new cache entry | ||
set(_pairs "") | ||
foreach(_k IN LISTS _new) | ||
if(NOT "${_k}" MATCHES "^((C|CXX)_SUPPORTS|HAVE_|GLIBCXX_USE|SUPPORTS_FVISI)") | ||
continue() | ||
endif() | ||
# Cache VALUE: dereference is fine here because cache entries read like normal vars | ||
set(_val "${${_k}}") | ||
# Cache TYPE (e.g., STRING, BOOL, PATH, FILEPATH, INTERNAL, UNINITIALIZED) | ||
get_property(_type CACHE "${_k}" PROPERTY TYPE) | ||
if(NOT _type) | ||
set(_type "UNINITIALIZED") | ||
endif() | ||
list(APPEND _pairs "set(${_k} \"${_val}\" CACHE ${_type} \"\")") | ||
endforeach() | ||
|
||
set(${out_var} "${_pairs}" PARENT_SCOPE) | ||
endfunction() |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -56,17 +56,25 @@ endfunction(find_all_header_files) | |||||||||||||||||||||
function(llvm_process_sources OUT_VAR) | ||||||||||||||||||||||
cmake_parse_arguments(ARG "PARTIAL_SOURCES_INTENDED" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN}) | ||||||||||||||||||||||
set(sources ${ARG_UNPARSED_ARGUMENTS}) | ||||||||||||||||||||||
llvm_check_source_file_list(${sources}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
# This adds .td and .h files to the Visual Studio solution: | ||||||||||||||||||||||
add_td_sources(sources) | ||||||||||||||||||||||
find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}") | ||||||||||||||||||||||
if (hdrs) | ||||||||||||||||||||||
set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON) | ||||||||||||||||||||||
if(LLVM_ENABLE_EXPENSIVE_CMAKE_CHECKS) | ||||||||||||||||||||||
llvm_check_source_file_list(${sources}) | ||||||||||||||||||||||
endif() | ||||||||||||||||||||||
|
||||||||||||||||||||||
if(ARG_ADDITIONAL_HEADERS) | ||||||||||||||||||||||
set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON) | ||||||||||||||||||||||
list(APPEND sources ${ARG_ADDITIONAL_HEADERS}) | ||||||||||||||||||||||
endif() | ||||||||||||||||||||||
set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON) | ||||||||||||||||||||||
list(APPEND sources ${ARG_ADDITIONAL_HEADERS} ${hdrs}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
# This adds .td and .h files to the Visual Studio solution: | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition logic has changed from always executing to conditional execution based on
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||
if(MSVC OR LLVM_ENABLE_EXPENSIVE_CMAKE_CHECKS) | ||||||||||||||||||||||
add_td_sources(sources) | ||||||||||||||||||||||
find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}") | ||||||||||||||||||||||
if (hdrs) | ||||||||||||||||||||||
set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON) | ||||||||||||||||||||||
endif() | ||||||||||||||||||||||
list(APPEND sources ${hdrs}) | ||||||||||||||||||||||
endif() | ||||||||||||||||||||||
set( ${OUT_VAR} ${sources} PARENT_SCOPE ) | ||||||||||||||||||||||
endfunction(llvm_process_sources) | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern
SUPPORTS_FVISI
appears to be incomplete or a typo. This likely should beSUPPORTS_FVISIBILITY
or similar. The incomplete pattern may not match intended cache variables.Copilot uses AI. Check for mistakes.