From 355464e1ebd135fc1d44d8b19f26a3821520bbb3 Mon Sep 17 00:00:00 2001 From: Benoit Denkinger Date: Wed, 18 Feb 2026 17:19:53 +0100 Subject: [PATCH 1/7] unset INCDIR and CMP_DEF args otherwise they get appended for every library. --- cmake/sim/cadence/xcelium.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/sim/cadence/xcelium.cmake b/cmake/sim/cadence/xcelium.cmake index 35bbdb86..4b4dd727 100644 --- a/cmake/sim/cadence/xcelium.cmake +++ b/cmake/sim/cadence/xcelium.cmake @@ -327,10 +327,12 @@ function(__xcelium_compile_lib IP_LIB) get_ip_include_directories(SV_INC_DIRS ${lib} SYSTEMVERILOG VERILOG ${ARG_FILE_SETS}) get_ip_compile_definitions(SV_COMP_DEFS ${lib} SYSTEMVERILOG VERILOG ${ARG_FILE_SETS}) + unset(SV_ARG_INCDIRS) foreach(dir ${SV_INC_DIRS}) list(APPEND SV_ARG_INCDIRS -INCDIR ${dir}) endforeach() + unset(SV_CMP_DEFS_ARG) foreach(def ${SV_COMP_DEFS}) list(APPEND SV_CMP_DEFS_ARG -DEFINE ${def}) endforeach() From 204d320b42ed27ff3be4471229aa27b63cc509d0 Mon Sep 17 00:00:00 2001 From: Benoit Denkinger Date: Wed, 4 Mar 2026 11:57:14 +0100 Subject: [PATCH 2/7] Fix missing unset in vivado_sim and formated xcelium function as the others. --- cmake/sim/cadence/xcelium.cmake | 4 ++-- cmake/sim/xilinx/vivado_sim.cmake | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/sim/cadence/xcelium.cmake b/cmake/sim/cadence/xcelium.cmake index 4b4dd727..552ec315 100644 --- a/cmake/sim/cadence/xcelium.cmake +++ b/cmake/sim/cadence/xcelium.cmake @@ -323,16 +323,16 @@ function(__xcelium_compile_lib IP_LIB) get_ip_sources(SV_SOURCES ${lib} SYSTEMVERILOG VERILOG NO_DEPS ${ARG_FILE_SETS}) get_ip_sources(SV_HEADERS ${lib} SYSTEMVERILOG VERILOG HEADERS ${ARG_FILE_SETS}) unset(sv_compile_cmd) + unset(SV_ARG_INCDIRS) + unset(SV_CMP_DEFS_ARG) if(SV_SOURCES) get_ip_include_directories(SV_INC_DIRS ${lib} SYSTEMVERILOG VERILOG ${ARG_FILE_SETS}) get_ip_compile_definitions(SV_COMP_DEFS ${lib} SYSTEMVERILOG VERILOG ${ARG_FILE_SETS}) - unset(SV_ARG_INCDIRS) foreach(dir ${SV_INC_DIRS}) list(APPEND SV_ARG_INCDIRS -INCDIR ${dir}) endforeach() - unset(SV_CMP_DEFS_ARG) foreach(def ${SV_COMP_DEFS}) list(APPEND SV_CMP_DEFS_ARG -DEFINE ${def}) endforeach() diff --git a/cmake/sim/xilinx/vivado_sim.cmake b/cmake/sim/xilinx/vivado_sim.cmake index d5c5e291..0712f57c 100644 --- a/cmake/sim/xilinx/vivado_sim.cmake +++ b/cmake/sim/xilinx/vivado_sim.cmake @@ -176,6 +176,8 @@ function(__vivado_sim_compile_lib IP_LIB) # SystemVerilog and Verilog files and arguments get_ip_sources(SV_SOURCES ${lib} SYSTEMVERILOG VERILOG NO_DEPS ${ARG_FILE_SETS}) unset(__xvlog_cmd) + unset(SV_ARG_INCDIRS) + unset(SV_CMP_DEFS_ARG) if(SV_SOURCES) get_ip_include_directories(SV_INC_DIRS ${lib} SYSTEMVERILOG VERILOG ${ARG_FILE_SETS}) get_ip_compile_definitions(SV_COMP_DEFS ${lib} SYSTEMVERILOG VERILOG ${ARG_FILE_SETS}) From 30c088178a1d8bb1dcafa5d05677b0915a1f292d Mon Sep 17 00:00:00 2001 From: Benoit Denkinger Date: Wed, 7 Jan 2026 15:07:42 +0100 Subject: [PATCH 3/7] Added EXCLUDED_IPS keyword parameters to hwip functions and used a different function that flatten_graph. --- cmake/hwip.cmake | 98 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 11 deletions(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index 8a928f16..af80fad5 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -328,9 +328,11 @@ endfunction() # :type [HEADERS]: bool # :keyword [FILE_SETS]: Specify list of File sets to retrieve the files from # :type [FILE_SETS]: list[string] +# :keyword [EXCLUDED_IPS]: Exclude the IPs of the source file search. +# :type [FILE_SETS]: list[string] #]] function(get_ip_sources OUTVAR IP_LIB LANGUAGE) - cmake_parse_arguments(ARG "NO_DEPS;HEADERS" "" "FILE_SETS" ${ARGN}) + cmake_parse_arguments(ARG "NO_DEPS;HEADERS" "" "FILE_SETS;EXCLUDED_IPS" ${ARGN}) alias_dereference(_reallib ${IP_LIB}) # Handle NO_DEPS flag @@ -347,6 +349,15 @@ function(get_ip_sources OUTVAR IP_LIB LANGUAGE) set(property_type HEADERS) list(REMOVE_ITEM ARGN HEADERS) endif() + + if(ARG_EXCLUDED_IPS) + # Clean ARGN from EXCLUDED_IPS and listed IPs + foreach(ip ${ARG_EXCLUDED_IPS}) + list(REMOVE_ITEM ARGN "${ip}") + endforeach() + list(REMOVE_ITEM ARGN "EXCLUDED_IPS") + set(ARG_EXCLUDED_IPS EXCLUDED_IPS ${ARG_EXCLUDED_IPS}) + endif() # In case FILE_SETS function argument is not passed, return all file sets that were defined in IP or sub IPs # Otherwise return only files in listed in FILE_SETS argument @@ -374,9 +385,11 @@ function(get_ip_sources OUTVAR IP_LIB LANGUAGE) if(_no_deps) set(ips ${_reallib}) else() - get_ip_links(ips ${_reallib}) + get_ip_links(ips ${_reallib} ${ARG_EXCLUDED_IPS}) endif() + # message(STATUS "-- ${CMAKE_CURRENT_FUNCTION}: ") + set(asked_languges ${LANGUAGE} ${ARGN}) unset(SOURCES) # Get all the __SOURCES or __HEADERS lists in order @@ -671,10 +684,9 @@ function(get_ip_property OUTVAR IP_LIB PROPERTY) set(OUT_LIST ${prop}) endif() else() - # Flatten the target graph to get all the dependencies in the correct order - flatten_graph_if_allowed(${_reallib}) - # Get all the dependencies - get_target_property(DEPS ${_reallib} FLAT_GRAPH) + # Get all the IP dependencies + ip_recursive_get_target_property(_linked_ips ${_reallib} INTERFACE_LINK_LIBRARIES ${ARG_EXCLUDED_IPS}) + set(DEPS ${_linked_ips} ${_reallib}) # Append the property of all the deps into a single list (e.g., the source files of an IP) foreach(d ${DEPS}) @@ -812,7 +824,7 @@ function(get_ip_compile_definitions OUTVAR IP_LIB LANGUAGE) endfunction() #[[[ -# Get the IP link graph in a flat list +# Get the IP link graph in a flat list, including the given IP. # # :param OUTVAR: Variable containing the link list. # :type OUTVAR: string @@ -820,7 +832,7 @@ endfunction() # :type [NO_DEPS]: bool #]] function(get_ip_links OUTVAR IP_LIB) - cmake_parse_arguments(ARG "NO_DEPS" "" "" ${ARGN}) + cmake_parse_arguments(ARG "NO_DEPS" "" "EXCLUDED_IPS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() @@ -830,12 +842,14 @@ function(get_ip_links OUTVAR IP_LIB) if(ARG_NO_DEPS) get_property(__flat_graph TARGET ${_reallib} PROPERTY INTERFACE_LINK_LIBRARIES) else() - flatten_graph_if_allowed(${_reallib}) + if(ARG_EXCLUDED_IPS) + set(ARG_EXCLUDED_IPS EXCLUDED_IPS ${ARG_EXCLUDED_IPS}) + endif() - get_property(__flat_graph TARGET ${_reallib} PROPERTY FLAT_GRAPH) + ip_recursive_get_target_property(__linked_ips ${_reallib} INTERFACE_LINK_LIBRARIES ${ARG_EXCLUDED_IPS}) endif() - set(${OUTVAR} ${__flat_graph} PARENT_SCOPE) + set(${OUTVAR} ${__linked_ips} ${_reallib} PARENT_SCOPE) endfunction() #[[[ @@ -963,3 +977,65 @@ function(flatten_graph_if_allowed IP_LIB) flatten_graph(${IP_LIB}) endif() endfunction() + +#[[[ +# This function recursively get the property PROPERTY from the target IP_LIB and +# returns a list stored in OUTVAR. +# +# :param OUT_VAR: Variable containing the requested property. +# :type OUT_VAR: string +# :param IP_LIB: The target IP library name. +# :type IP_LIB: string +# :param PROPERTY: Property to search recursively. +# :type PROPERTY: string +# +#]] +function(ip_recursive_get_target_property OUTVAR IP_LIB PROPERTY) + cmake_parse_arguments(ARG "" "" "EXCLUDED_IPS" ${ARGN}) + if(ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") + endif() + + if(ARG_EXCLUDED_IPS) + set(ARG_EXCLUDED_IPS EXCLUDED_IPS ${ARG_EXCLUDED_IPS}) + endif() + + set(_seen_values) + + alias_dereference(_reallib ${IP_LIB}) + + foreach(excl_ip ${ARG_EXCLUDED_IPS}) + alias_dereference(_excl_ip_reallib ${excl_ip}) + set(_excluded_ips_reallib_list ${_excluded_ips_reallib_list} ${_excl_ip_reallib}) + endforeach() + + # Get the value of the specified property for the current target + get_target_property(_current_value ${_reallib} ${PROPERTY}) + + if(_current_value AND NOT _current_value STREQUAL "<${PROPERTY}>-NOTFOUND") + # Check every entry + foreach(_subtarget ${_current_value}) + # Recursively process sub-targets if they exist + if(TARGET ${_subtarget}) + # Stop the recursive search if the IP is excluded + if(ARG_EXCLUDED_IPS AND NOT ${_subtarget} IN_LIST _excluded_ips_reallib_list) + # Add the current target to the list + list(APPEND _seen_values ${_subtarget}) + # Recusrive call to search for the property in the sub-target + ip_recursive_get_target_property(_recursive_values ${_subtarget} ${PROPERTY} ${ARG_EXCLUDED_IPS}) + # Add the recursively collected target to the list + list(APPEND _seen_values ${_recursive_values}) + # Remove duplicates keeping the first appearing instance + list(REMOVE_DUPLICATES _seen_values) + else() + message(DEBUG "-- ${CMAKE_CURRENT_FUNCTION}: ip target ${_subtarget} is excluded from search") + endif() + endif() + endforeach() + endif() + + message(DEBUG "-- ${CMAKE_CURRENT_FUNCTION}: ${_reallib} _seen_values: ${_seen_values}") + + # Return the collected values + set(${OUTVAR} ${_seen_values} PARENT_SCOPE) +endfunction() From f74f38243fdbae4c0205198006baf79a7caad793 Mon Sep 17 00:00:00 2001 From: Benoit Denkinger Date: Thu, 8 Jan 2026 14:44:57 +0100 Subject: [PATCH 4/7] Fixed ip_recursive_get_target_property for correct order of target prepending the list during recursive search. --- cmake/hwip.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index af80fad5..b6a81c8c 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -1004,6 +1004,8 @@ function(ip_recursive_get_target_property OUTVAR IP_LIB PROPERTY) alias_dereference(_reallib ${IP_LIB}) + set(_excluded_ips_reallib_list) + foreach(excl_ip ${ARG_EXCLUDED_IPS}) alias_dereference(_excl_ip_reallib ${excl_ip}) set(_excluded_ips_reallib_list ${_excluded_ips_reallib_list} ${_excl_ip_reallib}) @@ -1018,20 +1020,24 @@ function(ip_recursive_get_target_property OUTVAR IP_LIB PROPERTY) # Recursively process sub-targets if they exist if(TARGET ${_subtarget}) # Stop the recursive search if the IP is excluded - if(ARG_EXCLUDED_IPS AND NOT ${_subtarget} IN_LIST _excluded_ips_reallib_list) + if(NOT ${_subtarget} IN_LIST _excluded_ips_reallib_list) # Add the current target to the list list(APPEND _seen_values ${_subtarget}) # Recusrive call to search for the property in the sub-target ip_recursive_get_target_property(_recursive_values ${_subtarget} ${PROPERTY} ${ARG_EXCLUDED_IPS}) # Add the recursively collected target to the list - list(APPEND _seen_values ${_recursive_values}) + list(PREPEND _seen_values ${_recursive_values}) # Remove duplicates keeping the first appearing instance list(REMOVE_DUPLICATES _seen_values) else() message(DEBUG "-- ${CMAKE_CURRENT_FUNCTION}: ip target ${_subtarget} is excluded from search") endif() + else() + message(DEBUG "-- ${CMAKE_CURRENT_FUNCTION}: ${_subtarget} is not a target, not added to seen values") endif() endforeach() + else() + message(DEBUG "-- ${CMAKE_CURRENT_FUNCTION}: target ${_reallib} has no property ${PROPERTY} or it is not set") endif() message(DEBUG "-- ${CMAKE_CURRENT_FUNCTION}: ${_reallib} _seen_values: ${_seen_values}") From c40b647446d8c96e7ca242ad9fb77398ecee801a Mon Sep 17 00:00:00 2001 From: Benoit Denkinger Date: Thu, 8 Jan 2026 17:19:23 +0100 Subject: [PATCH 5/7] ip_recursive_get_target_property description updated. --- cmake/hwip.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index b6a81c8c..4986a5d5 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -980,7 +980,7 @@ endfunction() #[[[ # This function recursively get the property PROPERTY from the target IP_LIB and -# returns a list stored in OUTVAR. +# returns a list stored in OUTVAR respecting the hierarchy order of traversed targets. # # :param OUT_VAR: Variable containing the requested property. # :type OUT_VAR: string From 03be9728150b446ebc5169f05dcae080c2bace3d Mon Sep 17 00:00:00 2001 From: Benoit Denkinger Date: Mon, 16 Feb 2026 09:32:52 +0100 Subject: [PATCH 6/7] alias_dereference called on exlcuded IPs. --- cmake/hwip.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index 4986a5d5..b174348f 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -351,12 +351,18 @@ function(get_ip_sources OUTVAR IP_LIB LANGUAGE) endif() if(ARG_EXCLUDED_IPS) + set(EXCLUDED_REAL_IPS "") # Clean ARGN from EXCLUDED_IPS and listed IPs foreach(ip ${ARG_EXCLUDED_IPS}) list(REMOVE_ITEM ARGN "${ip}") + alias_dereference(_excluded_ip ${ip}) + list(APPEND EXCLUDED_REAL_IPS ${_excluded_ip}) + message(STATUS "-- ${CMAKE_CURRENT_FUNCTION}: Excluding IP ${ip} (real name: ${_excluded_ip}) from the list of IPs to search for sources") endforeach() + # Remove the EXCLUDED_IPS keyword from ARGN list(REMOVE_ITEM ARGN "EXCLUDED_IPS") - set(ARG_EXCLUDED_IPS EXCLUDED_IPS ${ARG_EXCLUDED_IPS}) + # Get the real IP names (not the aliases) + set(ARG_EXCLUDED_IPS EXCLUDED_IPS ${EXCLUDED_REAL_IPS}) endif() # In case FILE_SETS function argument is not passed, return all file sets that were defined in IP or sub IPs From c55caba52a67ecb6be3a8bc89a48fc0f0e7ef999 Mon Sep 17 00:00:00 2001 From: Benoit Denkinger Date: Tue, 17 Feb 2026 14:49:58 +0100 Subject: [PATCH 7/7] Getting read of __flat_graph in get_ip_links and added NO_DEPS to ip_recursive_get_target_property. --- cmake/hwip.cmake | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index b174348f..240e2892 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -845,16 +845,16 @@ function(get_ip_links OUTVAR IP_LIB) alias_dereference(_reallib ${IP_LIB}) - if(ARG_NO_DEPS) - get_property(__flat_graph TARGET ${_reallib} PROPERTY INTERFACE_LINK_LIBRARIES) - else() - if(ARG_EXCLUDED_IPS) - set(ARG_EXCLUDED_IPS EXCLUDED_IPS ${ARG_EXCLUDED_IPS}) - endif() + if(ARG_EXCLUDED_IPS) + set(ARG_EXCLUDED_IPS EXCLUDED_IPS ${ARG_EXCLUDED_IPS}) + endif() - ip_recursive_get_target_property(__linked_ips ${_reallib} INTERFACE_LINK_LIBRARIES ${ARG_EXCLUDED_IPS}) + if(ARG_NO_DEPS) + set(ARG_NO_DEPS NO_DEPS) endif() + ip_recursive_get_target_property(__linked_ips ${_reallib} INTERFACE_LINK_LIBRARIES ${ARG_EXCLUDED_IPS} ${ARG_NO_DEPS}) + set(${OUTVAR} ${__linked_ips} ${_reallib} PARENT_SCOPE) endfunction() @@ -997,7 +997,7 @@ endfunction() # #]] function(ip_recursive_get_target_property OUTVAR IP_LIB PROPERTY) - cmake_parse_arguments(ARG "" "" "EXCLUDED_IPS" ${ARGN}) + cmake_parse_arguments(ARG "NO_DEPS" "" "EXCLUDED_IPS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() @@ -1029,10 +1029,12 @@ function(ip_recursive_get_target_property OUTVAR IP_LIB PROPERTY) if(NOT ${_subtarget} IN_LIST _excluded_ips_reallib_list) # Add the current target to the list list(APPEND _seen_values ${_subtarget}) - # Recusrive call to search for the property in the sub-target - ip_recursive_get_target_property(_recursive_values ${_subtarget} ${PROPERTY} ${ARG_EXCLUDED_IPS}) - # Add the recursively collected target to the list - list(PREPEND _seen_values ${_recursive_values}) + if(NOT ARG_NO_DEPS) + # Recursive call to search for the property in the sub-target only if NO_DEPS is not set + ip_recursive_get_target_property(_recursive_values ${_subtarget} ${PROPERTY} ${ARG_EXCLUDED_IPS}) + # Add the recursively collected target to the list + list(PREPEND _seen_values ${_recursive_values}) + endif() # Remove duplicates keeping the first appearing instance list(REMOVE_DUPLICATES _seen_values) else()