@@ -275,8 +275,8 @@ function(xrepo_package package)
275275 set (configs "${_config_lua_script} " )
276276 # Trigger cmake configure when ${_config_lua_script} changes.
277277 set_property (
278- DIRECTORY
279- APPEND
278+ DIRECTORY
279+ APPEND
280280 PROPERTY CMAKE_CONFIGURE_DEPENDS
281281 "${_config_lua_script} "
282282 )
@@ -404,6 +404,10 @@ function(xrepo_target_packages target)
404404 message (STATUS "xrepo: target_link_libraries(${target} ${_visibility} ${${package_name} _LIBRARIES})" )
405405 target_link_libraries (${target} ${_visibility} ${${package_name} _LIBRARIES})
406406 endif ()
407+ if ((DEFINED ${package_name} _SYS_LIBRARIES) AND (NOT ARG_NO_LINK_LIBRARIES))
408+ message (STATUS "xrepo: target_link_libraries(${target} ${_visibility} ${${package_name} _SYS_LIBRARIES})" )
409+ target_link_libraries (${target} ${_visibility} ${${package_name} _SYS_LIBRARIES})
410+ endif ()
407411 if (DEFINED ${package_name} _DEFINITIONS)
408412 message (STATUS "xrepo: target_compile_definitions(${target} ${_visibility} ${${package_name} _DEFINITIONS})" )
409413 target_compile_definitions (${target} ${_visibility} ${${package_name} _DEFINITIONS})
@@ -508,60 +512,90 @@ macro(_xrepo_fetch_json)
508512 math (EXPR len_end "${len} - 1" )
509513 foreach (idx RANGE 0 ${len_end} )
510514 # Loop over includedirs.
511- string (JSON includedirs_len ERROR_VARIABLE includedirs_error LENGTH ${json_output} ${idx} "includedirs" )
512- if ("${includedirs_error} " STREQUAL "NOTFOUND" AND NOT "${includedirs_len} " EQUAL 0)
513- math (EXPR includedirs_end "${includedirs_len} - 1" )
514- foreach (includedirs_idx RANGE 0 ${includedirs_end} )
515- string (JSON dir GET ${json_output} ${idx} includedirs ${includedirs_idx} )
516- # It's difficult to know package name while looping over all packages.
517- # Thus we use list to collect all include and link dirs.
518- list (APPEND includedirs ${dir} )
519- #message(STATUS "xrepo DEBUG: includedirs ${idx} ${includedirs_idx} ${dir}")
520- endforeach ()
515+ string (JSON includedirs_type ERROR_VARIABLE includedirs_error TYPE ${json_output} ${idx} "includedirs" )
516+ if ("${includedirs_type} " STREQUAL "STRING" )
517+ string (JSON dir GET ${json_output} ${idx} "includedirs" )
518+ list (APPEND includedirs ${dir} )
519+ elseif ("${includedirs_type} " MATCHES "ARRAY|OBJECT" )
520+ string (JSON includedirs_len ERROR_VARIABLE includedirs_error LENGTH ${json_output} ${idx} "includedirs" )
521+ if ("${includedirs_error} " STREQUAL "NOTFOUND" AND NOT "${includedirs_len} " EQUAL 0)
522+ math (EXPR includedirs_end "${includedirs_len} - 1" )
523+ foreach (includedirs_idx RANGE 0 ${includedirs_end} )
524+ string (JSON dir GET ${json_output} ${idx} "includedirs" ${includedirs_idx} )
525+ # It's difficult to know package name while looping over all packages.
526+ # Thus we use list to collect all include and link dirs.
527+ list (APPEND includedirs ${dir} )
528+ #message(STATUS "xrepo DEBUG: includedirs ${idx} ${includedirs_idx} ${dir}")
529+ endforeach ()
530+ endif ()
521531 endif ()
522532
523533 # Loop over linkdirs.
524- string (JSON linkdirs_len ERROR_VARIABLE linkdirs_error LENGTH ${json_output} ${idx} "linkdirs" )
525- if ("${linkdirs_error} " STREQUAL "NOTFOUND" AND NOT "${linkdirs_len} " EQUAL 0)
526- math (EXPR linkdirs_end "${linkdirs_len} - 1" )
527- foreach (linkdirs_idx RANGE 0 ${linkdirs_end} )
528- string (JSON dir GET ${json_output} ${idx} linkdirs ${linkdirs_idx} )
529- list (APPEND linkdirs ${dir} )
530- #message(STATUS "xrepo DEBUG: linkdirs ${idx} ${linkdirs_idx} ${dir}")
531- endforeach ()
534+ string (JSON linkdirs_type ERROR_VARIABLE linkdirs_error TYPE ${json_output} ${idx} "linkdirs" )
535+ if ("${linkdirs_type} " STREQUAL "STRING" )
536+ string (JSON dir GET ${json_output} ${idx} "linkdirs" )
537+ list (APPEND linkdirs ${dir} )
538+ elseif ("${linkdirs_type} " MATCHES "ARRAY|OBJECT" )
539+ string (JSON linkdirs_len ERROR_VARIABLE linkdirs_error LENGTH ${json_output} ${idx} "linkdirs" )
540+ if ("${linkdirs_error} " STREQUAL "NOTFOUND" AND NOT "${linkdirs_len} " EQUAL 0)
541+ math (EXPR linkdirs_end "${linkdirs_len} - 1" )
542+ foreach (linkdirs_idx RANGE 0 ${linkdirs_end} )
543+ string (JSON dir GET ${json_output} ${idx} "linkdirs" ${linkdirs_idx} )
544+ list (APPEND linkdirs ${dir} )
545+ #message(STATUS "xrepo DEBUG: linkdirs ${idx} ${linkdirs_idx} ${dir}")
546+ endforeach ()
547+ endif ()
532548 endif ()
533549
534550 # Loop over links.
535- string (JSON links_len ERROR_VARIABLE links_error LENGTH ${json_output} ${idx} "links" )
536- if ("${links_error} " STREQUAL "NOTFOUND" AND NOT "${links_len} " EQUAL 0)
537- math (EXPR links_end "${links_len} - 1" )
538- foreach (links_idx RANGE 0 ${links_end} )
539- string (JSON dir GET ${json_output} ${idx} links ${links_idx} )
540- list (APPEND links ${dir} )
541- #message(STATUS "xrepo DEBUG: links ${idx} ${links_idx} ${dir}")
542- endforeach ()
551+ string (JSON links_type ERROR_VARIABLE links_error TYPE ${json_output} ${idx} "links" )
552+ if ("${links_type} " STREQUAL "STRING" )
553+ string (JSON dir GET ${json_output} ${idx} "links" )
554+ list (APPEND links ${dir} )
555+ elseif ("${links_type} " MATCHES "ARRAY|OBJECT" )
556+ string (JSON links_len ERROR_VARIABLE links_error LENGTH ${json_output} ${idx} "links" )
557+ if ("${links_error} " STREQUAL "NOTFOUND" AND NOT "${links_len} " EQUAL 0)
558+ math (EXPR links_end "${links_len} - 1" )
559+ foreach (links_idx RANGE 0 ${links_end} )
560+ string (JSON dir GET ${json_output} ${idx} "links" ${links_idx} )
561+ list (APPEND links ${dir} )
562+ #message(STATUS "xrepo DEBUG: links ${idx} ${links_idx} ${dir}")
563+ endforeach ()
564+ endif ()
543565 endif ()
544566
545567 # Loop over syslinks.
546- string (JSON syslinks_len ERROR_VARIABLE syslinks_error LENGTH ${json_output} ${idx} "syslinks" )
547- if ("${syslinks_error} " STREQUAL "NOTFOUND" AND NOT "${syslinks_len} " EQUAL 0)
548- math (EXPR syslinks_end "${syslinks_len} - 1" )
549- foreach (syslinks_idx RANGE 0 ${syslinks_end} )
550- string (JSON dir GET ${json_output} ${idx} syslinks ${syslinks_idx} )
551- list (APPEND syslinks ${dir} )
552- #message(STATUS "xrepo DEBUG: syslinks ${idx} ${syslinks_idx} ${dir}")
553- endforeach ()
568+ string (JSON syslinks_type ERROR_VARIABLE syslinks_error TYPE ${json_output} ${idx} "syslinks" )
569+ if ("${syslinks_type} " STREQUAL "STRING" )
570+ string (JSON dir GET ${json_output} ${idx} "syslinks" )
571+ list (APPEND syslinks ${dir} )
572+ elseif ("${syslinks_type} " MATCHES "ARRAY|OBJECT" )
573+ string (JSON syslinks_len ERROR_VARIABLE syslinks_error LENGTH ${json_output} ${idx} "syslinks" )
574+ if ("${syslinks_error} " STREQUAL "NOTFOUND" AND NOT "${syslinks_len} " EQUAL 0)
575+ math (EXPR syslinks_end "${syslinks_len} - 1" )
576+ foreach (syslinks_idx RANGE 0 ${syslinks_end} )
577+ string (JSON dir GET ${json_output} ${idx} "syslinks" ${syslinks_idx} )
578+ list (APPEND syslinks ${dir} )
579+ #message(STATUS "xrepo DEBUG: syslinks ${idx} ${syslinks_idx} ${dir}")
580+ endforeach ()
581+ endif ()
554582 endif ()
555583
556584 # Loop over defines.
557- string (JSON defines_len ERROR_VARIABLE defines_error LENGTH ${json_output} ${idx} "defines" )
558- if ("${defines_error} " STREQUAL "NOTFOUND" AND NOT "${defines_len} " EQUAL 0)
559- math (EXPR defines_end "${defines_len} - 1" )
560- foreach (defines_idx RANGE 0 ${defines_end} )
561- string (JSON dir GET ${json_output} ${idx} defines ${defines_idx} )
562- list (APPEND defines ${dir} )
563- #message(STATUS "xrepo DEBUG: defines ${idx} ${defines_idx} ${dir}")
564- endforeach ()
585+ string (JSON defines_type ERROR_VARIABLE defines_error TYPE ${json_output} ${idx} "defines" )
586+ if ("${defines_type} " STREQUAL "STRING" )
587+ string (JSON dir GET ${json_output} ${idx} "defines" )
588+ list (APPEND defines ${dir} )
589+ elseif ("${defines_type} " MATCHES "ARRAY|OBJECT" )
590+ string (JSON defines_len ERROR_VARIABLE defines_error LENGTH ${json_output} ${idx} "defines" )
591+ if ("${defines_error} " STREQUAL "NOTFOUND" AND NOT "${defines_len} " EQUAL 0)
592+ math (EXPR defines_end "${defines_len} - 1" )
593+ foreach (defines_idx RANGE 0 ${defines_end} )
594+ string (JSON dir GET ${json_output} ${idx} "defines" ${defines_idx} )
595+ list (APPEND defines ${dir} )
596+ #message(STATUS "xrepo DEBUG: defines ${idx} ${defines_idx} ${dir}")
597+ endforeach ()
598+ endif ()
565599 endif ()
566600 endforeach ()
567601
@@ -585,17 +619,16 @@ macro(_xrepo_fetch_json)
585619
586620 if (DEFINED links)
587621 set (${package_name} _LIBRARIES "${links} " CACHE INTERNAL "" )
588- set (${package_name} _LINK_LIBRARIES "${links} " CACHE INTERNAL "" ) # Keep compatibility, remove in the future.
589622 list (APPEND xrepo_vars_${package_name} ${package_name} _LIBRARIES)
590623 message (STATUS "xrepo: ${package_name} _LIBRARIES ${${package_name} _LIBRARIES}" )
591624 else ()
592625 message (STATUS "xrepo fetch --json: ${package_name} links not found" )
593626 endif ()
594627
595628 if (DEFINED syslinks)
596- set (${package_name} _LIBRARIES "${syslinks} " CACHE INTERNAL "" )
597- list (APPEND xrepo_vars_${package_name} ${package_name} _LIBRARIES )
598- message (STATUS "xrepo: ${package_name} _LIBRARIES ${${package_name} _LIBRARIES }" )
629+ set (${package_name} _SYS_LIBRARIES "${syslinks} " CACHE INTERNAL "" )
630+ list (APPEND xrepo_vars_${package_name} ${package_name} _SYS_LIBRARIES )
631+ message (STATUS "xrepo: ${package_name} _SYS_LIBRARIES ${${package_name} _SYS_LIBRARIES }" )
599632 endif ()
600633
601634 if (DEFINED defines)
0 commit comments