From 335445857b35bf7f60d9b1b42c0f151698ee7382 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Wed, 18 Aug 2021 00:25:23 -0700 Subject: [PATCH 01/10] [vcpkg baseline][vcpkg-fixup-cmake-targets] Add double quotes to `-framework NAME`on OSX --- ports/vcpkg-cmake-config/vcpkg.json | 2 +- ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake | 2 +- scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/vcpkg-cmake-config/vcpkg.json b/ports/vcpkg-cmake-config/vcpkg.json index 71d81f250c405a..e1890e3d17a0aa 100644 --- a/ports/vcpkg-cmake-config/vcpkg.json +++ b/ports/vcpkg-cmake-config/vcpkg.json @@ -1,4 +1,4 @@ { "name": "vcpkg-cmake-config", - "version-date": "2021-08-11" + "version-date": "2021-08-18" } diff --git a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake index 3cb60fe6bedd99..2cb6ae919ac599 100644 --- a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake +++ b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake @@ -250,7 +250,7 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]] endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "-framework ${name}" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "\"-framework ${name}\"" fixed_line "${fixed_line}") endif() endforeach() string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index 0641aa22404178..d2621b66eeba82 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -249,7 +249,7 @@ function(vcpkg_fixup_cmake_targets) endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "-framework ${name}" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "\"-framework ${name}\"" fixed_line "${fixed_line}") endif() endforeach() string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") From f8a45309a310bba4322ca2727e63fd4e41070b6f Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Wed, 18 Aug 2021 00:45:03 -0700 Subject: [PATCH 02/10] version --- versions/baseline.json | 2 +- versions/v-/vcpkg-cmake-config.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index 28551738f9eb5a..11f44b18c52772 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6617,7 +6617,7 @@ "port-version": 0 }, "vcpkg-cmake-config": { - "baseline": "2021-08-11", + "baseline": "2021-08-18", "port-version": 0 }, "vcpkg-gfortran": { diff --git a/versions/v-/vcpkg-cmake-config.json b/versions/v-/vcpkg-cmake-config.json index affac6bbe95ddc..5ffdb7e7d1c03b 100644 --- a/versions/v-/vcpkg-cmake-config.json +++ b/versions/v-/vcpkg-cmake-config.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "dd7d67c81c2442c831a298d136b019a2bd138565", + "version-date": "2021-08-18", + "port-version": 0 + }, { "git-tree": "b3abb12ba8ab43770aea4e5a8d4915319bd295ee", "version-date": "2021-08-11", From d4fbc48b1dc99a448d3f9877cff284d9fede4b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Wed, 18 Aug 2021 15:58:59 +0800 Subject: [PATCH 03/10] Update ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake --- ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake index 2cb6ae919ac599..f72ae7388ca3eb 100644 --- a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake +++ b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake @@ -250,7 +250,7 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]] endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "\"-framework ${name}\"" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "\\\"-framework ${name}\\\"" fixed_line "${fixed_line}") endif() endforeach() string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") From 27f7ee830ab4f1488e0b84e1ef8ba33f69dcabee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Wed, 18 Aug 2021 15:59:03 +0800 Subject: [PATCH 04/10] Update scripts/cmake/vcpkg_fixup_cmake_targets.cmake --- scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index d2621b66eeba82..a36517a03167db 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -249,7 +249,7 @@ function(vcpkg_fixup_cmake_targets) endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "\"-framework ${name}\"" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "\\\"-framework ${name}\\\"" fixed_line "${fixed_line}") endif() endforeach() string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") From abbb4cdffc5dd1f3acc10603784e20dc48750163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Wed, 18 Aug 2021 16:22:07 +0800 Subject: [PATCH 05/10] Update scripts/cmake/vcpkg_fixup_cmake_targets.cmake --- scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index a36517a03167db..dbb4909bb65f36 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -249,7 +249,7 @@ function(vcpkg_fixup_cmake_targets) endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "\\\"-framework ${name}\\\"" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "${name}.framework" fixed_line "${fixed_line}") endif() endforeach() string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") From fd228ab5666bca4215c0d199d3f0df424ddf8533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Wed, 18 Aug 2021 16:22:12 +0800 Subject: [PATCH 06/10] Update ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake --- ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake index f72ae7388ca3eb..39dfa05cd496a2 100644 --- a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake +++ b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake @@ -250,7 +250,7 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]] endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "\\\"-framework ${name}\\\"" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "${name}.framework" fixed_line "${fixed_line}") endif() endforeach() string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") From c2e31edc6914ad9ba3912c48bc9644a7ef75e3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Wed, 18 Aug 2021 17:42:40 +0800 Subject: [PATCH 07/10] Update ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake --- ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake index 39dfa05cd496a2..f72ae7388ca3eb 100644 --- a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake +++ b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake @@ -250,7 +250,7 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]] endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "${name}.framework" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "\\\"-framework ${name}\\\"" fixed_line "${fixed_line}") endif() endforeach() string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") From f61baf457c5a531c64235d4ca2fa05791f337777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Wed, 18 Aug 2021 17:42:45 +0800 Subject: [PATCH 08/10] Update scripts/cmake/vcpkg_fixup_cmake_targets.cmake --- scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index dbb4909bb65f36..a36517a03167db 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -249,7 +249,7 @@ function(vcpkg_fixup_cmake_targets) endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "${name}.framework" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "\\\"-framework ${name}\\\"" fixed_line "${fixed_line}") endif() endforeach() string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") From 87d30e895004780cc51cef7f3c9636d5d4d2c68a Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 19 Aug 2021 23:13:55 -0700 Subject: [PATCH 09/10] Rewrite the traversal code --- .../vcpkg_cmake_config_fixup.cmake | 25 +++++++++++++------ scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 25 +++++++++++++------ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake index 2cb6ae919ac599..73a94c0f53bf96 100644 --- a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake +++ b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake @@ -227,12 +227,17 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]] if (targets_files STREQUAL "") file(GLOB targets_files "${release_share}/*[Cc]onfig.cmake") endif() + # For every targets file foreach(targets_file IN LISTS targets_files) file(READ "${targets_file}" targets_content) - string(REGEX MATCHALL "INTERFACE_LINK_LIBRARIES[^\n]*\n" library_contents "${targets_content}") - foreach(line IN LISTS library_contents) - set(fixed_line "${line}") - string(REGEX MATCHALL [[/[^ ;"]+/[^ ;"/]+\.framework]] frameworks "${line}") + string(REGEX MATCHALL "INTERFACE_LINK_LIBRARIES[^\n]*\n" matched_lines "${targets_content}") + # For every line begin with `INTERFACE_LINK_LIBRARIES` + string(REGEX MATCH "INTERFACE_LINK_LIBRARIES[^\n]*\n" current_line "${matched_lines}") + while (current_line) + debug_message("current_line: ${current_line}") + set(fixed_line "${current_line}") + string(REGEX MATCHALL [[/[^ ;"]+/[^ ;"/]+\.framework]] frameworks "${current_line}") + # For every value in this line foreach(framework IN LISTS frameworks) if(NOT framework MATCHES [[^(.+)/(.+)\.framework$]]) continue() @@ -250,11 +255,17 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]] endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "\"-framework ${name}\"" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "-framework ${name}" fixed_line "${fixed_line}") endif() endforeach() - string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") - endforeach() + # Remove this line from list + string(REPLACE "${current_line}" "" matched_lines "${matched_lines}") + # Find the next line + string(REGEX MATCH "INTERFACE_LINK_LIBRARIES[^\n]*\n" current_line "${matched_lines}") + # Replace the fixed content in target file + debug_message("replace \"${current_line}\" with \"${fixed_line}\"") + string(REPLACE "${current_line}" "${fixed_line}" targets_content "${targets_content}") + endwhile() file(WRITE "${targets_file}" "${targets_content}") endforeach() endif() diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index d2621b66eeba82..2419e297f57174 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -226,12 +226,17 @@ function(vcpkg_fixup_cmake_targets) if (targets_files STREQUAL "") file(GLOB targets_files "${RELEASE_SHARE}/*[Cc]onfig.cmake") endif() + # For every targets file foreach(targets_file IN LISTS targets_files) file(READ "${targets_file}" targets_content) - string(REGEX MATCHALL "INTERFACE_LINK_LIBRARIES[^\n]*\n" library_contents "${targets_content}") - foreach(line IN LISTS library_contents) - set(fixed_line "${line}") - string(REGEX MATCHALL [[/[^ ;"]+/[^ ;"/]+\.framework]] frameworks "${line}") + string(REGEX MATCHALL "INTERFACE_LINK_LIBRARIES[^\n]*\n" matched_lines "${targets_content}") + # For every line begin with `INTERFACE_LINK_LIBRARIES` + string(REGEX MATCH "INTERFACE_LINK_LIBRARIES[^\n]*\n" current_line "${matched_lines}") + while (current_line) + debug_message("current_line: ${current_line}") + set(fixed_line "${current_line}") + string(REGEX MATCHALL [[/[^ ;"]+/[^ ;"/]+\.framework]] frameworks "${current_line}") + # For every value in this line foreach(framework IN LISTS frameworks) if(NOT framework MATCHES [[^(.+)/(.+)\.framework$]]) continue() @@ -249,11 +254,17 @@ function(vcpkg_fixup_cmake_targets) endif() list(FIND VCPKG_DETECTED_CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${path}" index) if(NOT index EQUAL -1) - string(REPLACE "${framework}" "\"-framework ${name}\"" fixed_line "${fixed_line}") + string(REPLACE "${framework}" "-framework ${name}" fixed_line "${fixed_line}") endif() endforeach() - string(REPLACE "${line}" "${fixed_line}" targets_content "${targets_content}") - endforeach() + # Remove this line from list + string(REPLACE "${current_line}" "" matched_lines "${matched_lines}") + # Find the next line + string(REGEX MATCH "INTERFACE_LINK_LIBRARIES[^\n]*\n" current_line "${matched_lines}") + # Replace the fixed content in target file + debug_message("replace \"${current_line}\" with \"${fixed_line}\"") + string(REPLACE "${current_line}" "${fixed_line}" targets_content "${targets_content}") + endwhile() file(WRITE "${targets_file}" "${targets_content}") endforeach() endif() From a9bd0691313dc7f24f1c3828c47bd2ebeb8e4a07 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 19 Aug 2021 23:37:26 -0700 Subject: [PATCH 10/10] Fix the order issue --- ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake | 6 +++--- scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake index 73a94c0f53bf96..7debcc275ae8f0 100644 --- a/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake +++ b/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake @@ -258,13 +258,13 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]] string(REPLACE "${framework}" "-framework ${name}" fixed_line "${fixed_line}") endif() endforeach() + # Replace the fixed content in target file + debug_message("replace \"${current_line}\" with \"${fixed_line}\"") + string(REPLACE "${current_line}" "${fixed_line}" targets_content "${targets_content}") # Remove this line from list string(REPLACE "${current_line}" "" matched_lines "${matched_lines}") # Find the next line string(REGEX MATCH "INTERFACE_LINK_LIBRARIES[^\n]*\n" current_line "${matched_lines}") - # Replace the fixed content in target file - debug_message("replace \"${current_line}\" with \"${fixed_line}\"") - string(REPLACE "${current_line}" "${fixed_line}" targets_content "${targets_content}") endwhile() file(WRITE "${targets_file}" "${targets_content}") endforeach() diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index 2419e297f57174..1a481997d84b0a 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -257,13 +257,13 @@ function(vcpkg_fixup_cmake_targets) string(REPLACE "${framework}" "-framework ${name}" fixed_line "${fixed_line}") endif() endforeach() + # Replace the fixed content in target file + debug_message("replace \"${current_line}\" with \"${fixed_line}\"") + string(REPLACE "${current_line}" "${fixed_line}" targets_content "${targets_content}") # Remove this line from list string(REPLACE "${current_line}" "" matched_lines "${matched_lines}") # Find the next line string(REGEX MATCH "INTERFACE_LINK_LIBRARIES[^\n]*\n" current_line "${matched_lines}") - # Replace the fixed content in target file - debug_message("replace \"${current_line}\" with \"${fixed_line}\"") - string(REPLACE "${current_line}" "${fixed_line}" targets_content "${targets_content}") endwhile() file(WRITE "${targets_file}" "${targets_content}") endforeach()