From 25663f218ce8f8f8b1b66ef515b3e7905c135447 Mon Sep 17 00:00:00 2001 From: Cheney Wang <38240633+Cheney-W@users.noreply.github.com> Date: Wed, 28 Dec 2022 13:07:26 -0800 Subject: [PATCH] [vcpkg baseline][ideviceinstaller] Fixing error LNK2005 when argtable2 installed before ideviceinstaller (#28459) * [ideviceinstaller] Add support !static * Modify port-version * x-add-version * Add getopt as a dependence of argtable2 * Use version * x-add-version * Remove space * Add license * Fix format error * x-add-version * update version * fix argtable3 * x-add-version * fix argtable3 * version * fix gdcm * format portfile.cmake * update version * format vcpkg.json * x-add-version * format portfile.cmake * x-add-version * Update license * x-add-version * Again * Mistake Co-authored-by: Lily Wang <494550702@qq.com> Co-authored-by: Lily Wang <94091114+LilyWangLL@users.noreply.github.com> --- .../0003-add-dependence-getopt.patch | 42 +++++++++++++++++++ ports/argtable2/portfile.cmake | 19 +++++---- ports/argtable2/vcpkg.json | 17 ++++++-- ports/argtable3/Fix-dependence-getopt.patch | 16 +++++++ ports/argtable3/portfile.cmake | 7 ++++ ports/argtable3/vcpkg.json | 8 +++- ports/gdcm/fix-dependence-getopt.patch | 39 +++++++++++++++++ ports/gdcm/portfile.cmake | 9 +++- ports/gdcm/vcpkg.json | 5 +++ ports/getopt-win32/CMakeLists.txt | 2 + ports/getopt-win32/vcpkg.json | 2 +- versions/a-/argtable2.json | 5 +++ versions/a-/argtable3.json | 5 +++ versions/baseline.json | 8 ++-- versions/g-/gdcm.json | 5 +++ versions/g-/getopt-win32.json | 5 +++ 16 files changed, 176 insertions(+), 18 deletions(-) create mode 100644 ports/argtable2/0003-add-dependence-getopt.patch create mode 100644 ports/argtable3/Fix-dependence-getopt.patch create mode 100644 ports/gdcm/fix-dependence-getopt.patch diff --git a/ports/argtable2/0003-add-dependence-getopt.patch b/ports/argtable2/0003-add-dependence-getopt.patch new file mode 100644 index 0000000000..422f76eee5 --- /dev/null +++ b/ports/argtable2/0003-add-dependence-getopt.patch @@ -0,0 +1,42 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8a4bd5b..7dc50f1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -9,6 +9,7 @@ endif(COMMAND cmake_policy) + + OPTION( HAVE_GETOPT_H "Have the getopt library" 0 ) + IF( HAVE_GETOPT_H ) ++ find_package(unofficial-getopt-win32 REQUIRED) + ADD_DEFINITIONS( -DHAVE_GETOPT_H ) + ENDIF( HAVE_GETOPT_H ) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 03e112c..8c58082 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -1,7 +1,12 @@ + include(GNUInstallDirs) + + IF( WIN32 ) ++ if(HAVE_GETOPT_H) ++ ADD_LIBRARY( argtable2 arg_dbl.c arg_end.c arg_file.c arg_int.c arg_lit.c arg_rem.c arg_str.c argtable2.c argtable2.h) ++ target_link_libraries(argtable2 PRIVATE unofficial::getopt-win32::getopt) ++ else() + ADD_LIBRARY( argtable2 arg_dbl.c arg_end.c arg_file.c arg_int.c arg_lit.c arg_rem.c arg_str.c argtable2.c argtable2.h getopt.c getopt.h getopt1.c ) ++ endif() + ELSE( WIN32 ) + ADD_LIBRARY( argtable2 arg_date.c arg_dbl.c arg_end.c arg_file.c arg_int.c arg_lit.c arg_rem.c arg_rex.c arg_str.c argtable2.c argtable2.h getopt.c getopt.h getopt1.c ) + ENDIF( WIN32 ) +diff --git a/src/argtable2.c b/src/argtable2.c +index c4d210c..1bc0a3e 100644 +--- a/src/argtable2.c ++++ b/src/argtable2.c +@@ -46,7 +46,7 @@ USA. + #endif + + #include "argtable2.h" +-#include "./getopt.h" ++//#include "./getopt.h" + + static + void arg_register_error(struct arg_end *end, void *parent, int error, const char *argval) diff --git a/ports/argtable2/portfile.cmake b/ports/argtable2/portfile.cmake index cf394f65a8..9fc7186e3c 100644 --- a/ports/argtable2/portfile.cmake +++ b/ports/argtable2/portfile.cmake @@ -9,18 +9,23 @@ vcpkg_from_sourceforge( PATCHES 0001-fix-install-dirs.patch 0002-include-correct-headers.patch + 0003-add-dependence-getopt.patch ) -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA +set(HAVE_GETOPT_H "") +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + set(HAVE_GETOPT_H 1) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" OPTIONS -DCMAKE_DEBUG_POSTFIX=d + -DHAVE_GETOPT_H=${HAVE_GETOPT_H} ) -vcpkg_install_cmake() -vcpkg_copy_pdbs() +vcpkg_cmake_install() -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/ports/argtable2/vcpkg.json b/ports/argtable2/vcpkg.json index 54431fc627..4d87c74c32 100644 --- a/ports/argtable2/vcpkg.json +++ b/ports/argtable2/vcpkg.json @@ -1,8 +1,19 @@ { "name": "argtable2", - "version-string": "2.13", - "port-version": 9, + "version": "2.13", + "port-version": 10, "description": "Argtable is an ANSI C library for parsing GNU style command line options with a minimum of fuss.", "homepage": "http://argtable.sourceforge.net", - "supports": "!uwp" + "license": "LGPL-2.0-only", + "supports": "!uwp", + "dependencies": [ + { + "name": "getopt", + "platform": "windows & !mingw" + }, + { + "name": "vcpkg-cmake", + "host": true + } + ] } diff --git a/ports/argtable3/Fix-dependence-getopt.patch b/ports/argtable3/Fix-dependence-getopt.patch new file mode 100644 index 0000000000..8f609cf605 --- /dev/null +++ b/ports/argtable3/Fix-dependence-getopt.patch @@ -0,0 +1,16 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 2e0b519..6b455dd 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -79,6 +79,11 @@ endif() + add_library(${ARGTABLE3_PROJECT_NAME}::argtable3 ALIAS argtable3) + target_include_directories(argtable3 PRIVATE ${PROJECT_SOURCE_DIR}/src) + ++if(NOT ARGTABLE3_REPLACE_GETOPT) ++ find_package(unofficial-getopt-win32 REQUIRED) ++ target_link_libraries(argtable3 PRIVATE unofficial::getopt-win32::getopt) ++endif() ++ + set_target_properties(argtable3 PROPERTIES + VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} + SOVERSION ${PROJECT_VERSION_MAJOR} diff --git a/ports/argtable3/portfile.cmake b/ports/argtable3/portfile.cmake index 428b9fa874..03aa90e5f4 100644 --- a/ports/argtable3/portfile.cmake +++ b/ports/argtable3/portfile.cmake @@ -4,14 +4,21 @@ vcpkg_from_github( REF 7704006f3cbb556e11da80a5b97469075a32892e # 3.2.1 + minor patches including ARGTABLE3_ENABLE_EXAMPLES support SHA512 c51aa0a33a247c3801e36ca5d9523acefa31f21a34c1e86965a39290c1b437785e4d7e0ae80a65d811803b8fcbbc3a96ba3d6aefaea9bda15abc0f38bd1f45cc HEAD_REF master + PATCHES Fix-dependence-getopt.patch ) +set(ARGTABLE3_REPLACE_GETOPT ON) +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + set(ARGTABLE3_REPLACE_GETOPT OFF) +endif() + vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS -DARGTABLE3_ENABLE_CONAN=OFF -DARGTABLE3_ENABLE_TESTS=OFF -DARGTABLE3_ENABLE_EXAMPLES=OFF + -DARGTABLE3_REPLACE_GETOPT=${ARGTABLE3_REPLACE_GETOPT} ) vcpkg_cmake_install() diff --git a/ports/argtable3/vcpkg.json b/ports/argtable3/vcpkg.json index 527cc3bdf6..2822477b0c 100644 --- a/ports/argtable3/vcpkg.json +++ b/ports/argtable3/vcpkg.json @@ -1,11 +1,15 @@ { "name": "argtable3", "version": "3.2.1", - "port-version": 2, + "port-version": 3, "description": "A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options", "homepage": "https://www.argtable.org/", - "license": "BSD-2-Clause-FreeBSD", + "license": "BSD-2-Clause-NetBSD AND TCL", "dependencies": [ + { + "name": "getopt", + "platform": "windows & !mingw" + }, { "name": "vcpkg-cmake", "host": true diff --git a/ports/gdcm/fix-dependence-getopt.patch b/ports/gdcm/fix-dependence-getopt.patch new file mode 100644 index 0000000000..556df7350e --- /dev/null +++ b/ports/gdcm/fix-dependence-getopt.patch @@ -0,0 +1,39 @@ +diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt +index 4cdc999..c6ede41 100644 +--- a/Utilities/CMakeLists.txt ++++ b/Utilities/CMakeLists.txt +@@ -69,6 +69,7 @@ if(NOT GDCM_USE_SYSTEM_ZLIB) + endif() + + # Do getopt ++if(NOT USE_VCPKG_GETOPT) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/getopt) + APPEND_COPYRIGHT(${CMAKE_CURRENT_SOURCE_DIR}/getopt/COPYING) + if(WIN32 AND NOT CYGWIN AND NOT MINGW) +@@ -79,6 +80,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/getopt) + add_subdirectory(getopt) + endif() + endif() ++endif() + + # you could be running mingw32 on linux in which case you do NOT want the gdcmuuid lib + APPEND_COPYRIGHT(${CMAKE_CURRENT_SOURCE_DIR}/gdcmuuid/COPYING) +diff --git a/Utilities/VTK/Applications/CMakeLists.txt b/Utilities/VTK/Applications/CMakeLists.txt +index c7f1ad9..20883a2 100644 +--- a/Utilities/VTK/Applications/CMakeLists.txt ++++ b/Utilities/VTK/Applications/CMakeLists.txt +@@ -45,7 +45,13 @@ foreach(app ${GDCM_VTK_APPS}) + target_link_libraries(${app} ${VTK_LIBRARIES} vtkIOXML) + endif() + if(WIN32 AND NOT CYGWIN) +- target_link_libraries(${app} gdcmgetopt) ++ if(USE_VCPKG_GETOPT) ++ find_package(unofficial-getopt-win32 REQUIRED) ++ target_link_libraries(${app} PRIVATE unofficial::getopt-win32::getopt) ++ else() ++ target_link_libraries(${app} gdcmgetopt) ++ endif() ++else() + endif() + if(NOT GDCM_INSTALL_NO_RUNTIME) + install(TARGETS ${app} diff --git a/ports/gdcm/portfile.cmake b/ports/gdcm/portfile.cmake index 3055b1a422..0f6b878662 100644 --- a/ports/gdcm/portfile.cmake +++ b/ports/gdcm/portfile.cmake @@ -10,6 +10,7 @@ vcpkg_from_github( use-openjpeg-config.patch fix-share-path.patch Fix-Cmake_DIR.patch + fix-dependence-getopt.patch ) file(REMOVE "${SOURCE_PATH}/CMake/FindOpenJPEG.cmake") @@ -20,6 +21,11 @@ else() set(VCPKG_BUILD_SHARED_LIBS OFF) endif() +set(USE_VCPKG_GETOPT OFF) +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + set(USE_VCPKG_GETOPT ON) +endif() + vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS @@ -30,6 +36,7 @@ vcpkg_cmake_configure( -DGDCM_USE_SYSTEM_ZLIB=ON -DGDCM_USE_SYSTEM_OPENJPEG=ON -DGDCM_BUILD_TESTING=OFF + -DUSE_VCPKG_GETOPT=${USE_VCPKG_GETOPT} ) vcpkg_cmake_install() @@ -59,4 +66,4 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") endif() -file(INSTALL "${SOURCE_PATH}/Copyright.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/Copyright.txt") diff --git a/ports/gdcm/vcpkg.json b/ports/gdcm/vcpkg.json index e0dedd842b..f14294e4b1 100644 --- a/ports/gdcm/vcpkg.json +++ b/ports/gdcm/vcpkg.json @@ -1,12 +1,17 @@ { "name": "gdcm", "version": "3.0.12", + "port-version": 1, "description": "Grassroots DICOM library", "homepage": "https://github.com/malaterre/GDCM", "license": "BSD-3-Clause", "supports": "!uwp & !(windows & arm)", "dependencies": [ "expat", + { + "name": "getopt", + "platform": "windows & !mingw" + }, "openjpeg", { "name": "vcpkg-cmake", diff --git a/ports/getopt-win32/CMakeLists.txt b/ports/getopt-win32/CMakeLists.txt index 338b528289..5bf9b11c8d 100644 --- a/ports/getopt-win32/CMakeLists.txt +++ b/ports/getopt-win32/CMakeLists.txt @@ -10,6 +10,8 @@ endif() add_library(getopt getopt.c) +TARGET_INCLUDE_DIRECTORIES(getopt INTERFACE $) + install( TARGETS getopt EXPORT unofficial-getopt-win32 diff --git a/ports/getopt-win32/vcpkg.json b/ports/getopt-win32/vcpkg.json index 501d997f84..bda4d6696d 100644 --- a/ports/getopt-win32/vcpkg.json +++ b/ports/getopt-win32/vcpkg.json @@ -1,7 +1,7 @@ { "name": "getopt-win32", "version": "0.1", - "port-version": 6, + "port-version": 7, "description": "An implementation of getopt.", "homepage": "https://github.com/libimobiledevice-win32/getopt", "license": "LGPL-3.0-only", diff --git a/versions/a-/argtable2.json b/versions/a-/argtable2.json index 28c3358465..d30fba4471 100644 --- a/versions/a-/argtable2.json +++ b/versions/a-/argtable2.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "931507f46135a9267c3d15ed5064235aac6154f4", + "version": "2.13", + "port-version": 10 + }, { "git-tree": "406503ece7b3ab95af28c6871a6de7263731f829", "version-string": "2.13", diff --git a/versions/a-/argtable3.json b/versions/a-/argtable3.json index a859cfbabe..44141564d2 100644 --- a/versions/a-/argtable3.json +++ b/versions/a-/argtable3.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "b84ef22a845ccccda6197d1865ddd1d8df9098c1", + "version": "3.2.1", + "port-version": 3 + }, { "git-tree": "fe3b1c9a876237412e7ba925a3b41f62e7fc1d99", "version": "3.2.1", diff --git a/versions/baseline.json b/versions/baseline.json index 8e38d139d2..84436ed4b9 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -170,11 +170,11 @@ }, "argtable2": { "baseline": "2.13", - "port-version": 9 + "port-version": 10 }, "argtable3": { "baseline": "3.2.1", - "port-version": 2 + "port-version": 3 }, "argumentum": { "baseline": "0.3.1", @@ -2566,7 +2566,7 @@ }, "gdcm": { "baseline": "3.0.12", - "port-version": 0 + "port-version": 1 }, "gdcm2": { "baseline": "deprecated", @@ -2610,7 +2610,7 @@ }, "getopt-win32": { "baseline": "0.1", - "port-version": 6 + "port-version": 7 }, "gettext": { "baseline": "0.21", diff --git a/versions/g-/gdcm.json b/versions/g-/gdcm.json index f18a8a6e17..09eb12e926 100644 --- a/versions/g-/gdcm.json +++ b/versions/g-/gdcm.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "cb3870f85a108727ba53c35d59633f9d6fdb4c4e", + "version": "3.0.12", + "port-version": 1 + }, { "git-tree": "d88a2229a173f1d38ae7beeb24d8169957968e74", "version": "3.0.12", diff --git a/versions/g-/getopt-win32.json b/versions/g-/getopt-win32.json index 8ec9ceaa49..79f9dcd1d2 100644 --- a/versions/g-/getopt-win32.json +++ b/versions/g-/getopt-win32.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "28d4331693c8c94a354365fff55df5f5762b7be6", + "version": "0.1", + "port-version": 7 + }, { "git-tree": "e2e91ce0684f0a2daa95adc45c9c32e61ae40a7e", "version": "0.1",