portfile.cmake 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. set(VERSION 3.100)
  2. vcpkg_from_sourceforge(
  3. OUT_SOURCE_PATH SOURCE_PATH
  4. REPO lame/lame
  5. REF ${VERSION}
  6. FILENAME "lame-${VERSION}.tar.gz"
  7. SHA512 0844b9eadb4aacf8000444621451277de365041cc1d97b7f7a589da0b7a23899310afd4e4d81114b9912aa97832621d20588034715573d417b2923948c08634b
  8. PATCHES
  9. 00001-msvc-upgrade-solution-up-to-vc11.patch
  10. remove_lame_init_old_from_symbol_list.patch # deprecated https://github.com/zlargon/lame/blob/master/include/lame.h#L169
  11. add-macos-universal-config.patch
  12. )
  13. if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
  14. if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
  15. set(platform "ARM64")
  16. set(machine "ARM64")
  17. elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
  18. set(platform "ARM")
  19. set(machine "ARM")
  20. elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
  21. set(platform "x64")
  22. set(machine "x64")
  23. else()
  24. set(platform "Win32")
  25. set(machine "x86")
  26. endif()
  27. file(READ "${SOURCE_PATH}/vc_solution/vc11_lame.sln" sln_con)
  28. string(REPLACE "|Win32" "|${platform}" sln_con "${sln_con}")
  29. string(REPLACE "\"vc11_" "\"${machine}_vc11_" sln_con "${sln_con}")
  30. file(WRITE "${SOURCE_PATH}/vc_solution/${machine}_vc11_lame.sln" "${sln_con}")
  31. file(GLOB vcxprojs RELATIVE "${SOURCE_PATH}/vc_solution" "${SOURCE_PATH}/vc_solution/vc11_*.vcxproj")
  32. foreach(vcxproj ${vcxprojs})
  33. file(READ "${SOURCE_PATH}/vc_solution/${vcxproj}" vcxproj_con)
  34. if(NOT VCPKG_CRT_LINKAGE STREQUAL dynamic)
  35. string(REPLACE "DLL</RuntimeLibrary>" "</RuntimeLibrary>" vcxproj_con "${vcxproj_con}")
  36. endif()
  37. string(REPLACE "/machine:x86" "/machine:${machine}" vcxproj_con "${vcxproj_con}")
  38. string(REPLACE "<Platform>Win32</Platform>" "<Platform>${platform}</Platform>" vcxproj_con "${vcxproj_con}")
  39. string(REPLACE "|Win32" "|${platform}" vcxproj_con "${vcxproj_con}")
  40. string(REPLACE "Include=\"vc11_" "Include=\"${machine}_vc11_" vcxproj_con "${vcxproj_con}")
  41. if(NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
  42. string(REPLACE "/APPCONTAINER" "" vcxproj_con "${vcxproj_con}")
  43. endif()
  44. file(WRITE "${SOURCE_PATH}/vc_solution/${machine}_${vcxproj}" "${vcxproj_con}")
  45. endforeach()
  46. vcpkg_install_msbuild(
  47. SOURCE_PATH "${SOURCE_PATH}"
  48. PROJECT_SUBPATH "vc_solution/${machine}_vc11_lame.sln"
  49. TARGET "lame"
  50. PLATFORM "${platform}"
  51. )
  52. if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
  53. if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
  54. file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin")
  55. file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libmp3lame.lib")
  56. endif()
  57. if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
  58. file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin")
  59. file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libmp3lame.lib")
  60. endif()
  61. set(MP3LAME_LIB "libmp3lame-static.lib")
  62. else()
  63. if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
  64. file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libmp3lame-static.lib")
  65. file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libmpghip-static.lib")
  66. endif()
  67. if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
  68. file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libmp3lame-static.lib")
  69. file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libmpghip-static.lib")
  70. endif()
  71. set(MP3LAME_LIB "libmp3lame.lib")
  72. endif()
  73. else()
  74. if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
  75. set(OPTIONS --enable-static=yes --enable-shared=no)
  76. set(MP3LAME_LIB "libmp3lame${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}")
  77. else()
  78. set(OPTIONS --enable-shared=yes --enable-static=no)
  79. if(VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX)
  80. set(MP3LAME_LIB "libmp3lame${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}")
  81. else()
  82. set(MP3LAME_LIB "libmp3lame${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}")
  83. endif()
  84. endif()
  85. if(NOT VCPKG_TARGET_IS_MINGW)
  86. string(APPEND OPTIONS --with-pic=yes)
  87. endif()
  88. vcpkg_configure_make(
  89. SOURCE_PATH "${SOURCE_PATH}"
  90. DETERMINE_BUILD_TRIPLET
  91. OPTIONS ${OPTIONS}
  92. )
  93. vcpkg_install_make()
  94. file(REMOVE_RECURSE
  95. "${CURRENT_PACKAGES_DIR}/debug/include"
  96. "${CURRENT_PACKAGES_DIR}/debug/share"
  97. )
  98. endif()
  99. file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/${PORT}/doc" "${CURRENT_PACKAGES_DIR}/share/${PORT}/man1")
  100. file(COPY "${SOURCE_PATH}/include/lame.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/lame")
  101. configure_file("${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/mp3lame-config.cmake" @ONLY)
  102. file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
  103. file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)