vcpkg/ports/wavpack/portfile.cmake
Kai Pastor 47633daa65
[vcpkg-scripts] Catch use of ambiguous cmake vars (#34546)
Avoid wrong use of popular but ambiguous variables (`WIN32` etc.) in
scripts and portfiles by detection in CI.

Sometimes the variables are used wrongly, and sometimes this isn't
caught in PR review. This PR tries to catch those variables (when in the
active code path in script mode). [This can happen to every
contributor](https://github.com/microsoft/vcpkg/pull/34356#discussion_r1360074122),
even if he/she knows the rules ... vcpkg is raising the bar higher than
usual, having to deal with targets and hosts even in script mode.

(`b2-options.cmake` (boost fragment) shows where we get if we don't pay
attention: the same code being used in script mode (`WIN32` meaning
host) and in project mode (`WIN32` meaning target).)

The new check doesn't break any user builds because it relies on command
line options. However it changes the ABI hashes.
2024-06-14 11:40:01 -07:00

46 lines
1.5 KiB
CMake

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO dbry/WavPack
REF 5.6.0
SHA512 16e1b5a74261843dff148eee6a83a0c84717477c06907af3ee1bc799f9157ba8c0d3c71eee9d93d74a1081151198a8a23d84c14a60c4b35fc145d10ee901cca1
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DWAVPACK_INSTALL_DOCS=OFF
-DWAVPACK_BUILD_PROGRAMS=OFF
-DWAVPACK_BUILD_COOLEDIT_PLUGIN=OFF
-DWAVPACK_BUILD_WINAMP_PLUGIN=OFF
-DBUILD_TESTING=OFF
-DWAVPACK_BUILD_DOCS=OFF
-DWAVPACK_ENABLE_LIBCRYPTO=OFF
)
vcpkg_cmake_install()
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_cmake_config_fixup(CONFIG_PATH cmake)
else()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/WavPack)
endif()
vcpkg_copy_pdbs()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/license.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/wavpack.pc" "-lwavpack" "-lwavpackdll")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/wavpack.pc" "-lwavpack" "-lwavpackdll")
endif()
endif()
endif()
vcpkg_fixup_pkgconfig()