Skip to content

Commit 78f2f05

Browse files
iboBDiamonDinoia
authored andcommitted
cmake: cache results of filter_supported_compiler_flags
1 parent c521f0c commit 78f2f05

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmake/utils.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ include(CheckCXXCompilerFlag)
22

33
# Define the function
44
function(filter_supported_compiler_flags input_flags_var output_flags_var)
5+
string(MD5 input_hash "${${input_flags_var}}")
6+
if(DEFINED SUPPORTED_FLAGS_${input_hash})
7+
message(STATUS "Using cached flags for ${input_flags_var}: ${SUPPORTED_FLAGS_${input_hash}}")
8+
set(${output_flags_var} ${SUPPORTED_FLAGS_${input_hash}} PARENT_SCOPE)
9+
return()
10+
endif()
11+
512
# Create an empty list to store supported flags
613
set(supported_flags)
714
# Iterate over each flag in the input list
@@ -23,7 +30,8 @@ function(filter_supported_compiler_flags input_flags_var output_flags_var)
2330
# remove last flag from CMAKE_EXE_LINKER_FLAGS using substring
2431
set(CMAKE_EXE_LINKER_FLAGS ${ORIGINAL_LINKER_FLAGS})
2532
endforeach()
26-
# Set the output variable to the list of supported flags
33+
# Set the output variable to the list of supported flags and cache them
34+
set(SUPPORTED_FLAGS_${input_hash} "${supported_flags}" CACHE INTERNAL "")
2735
set(${output_flags_var} ${supported_flags} PARENT_SCOPE)
2836
endfunction()
2937

0 commit comments

Comments
 (0)