On 07/01/2016 08:01 AM, Ruslan Baratov via cmake-developers wrote:
> With attached patch it's possible to extract name from URLs like
> 'https://.../archive.tar.gz?a=x&b=y'.
Thanks.
> elseif(NOT "${fname}" MATCHES
> "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
> - message(FATAL_ERROR "Could not extract tarball filename from
> url:\n ${url}")
> + # Try: https://.../archive.tar.gz?a=x&b=y
> + string(REGEX MATCH "^.*/([^/]*)\\?.*$" match_result "${url}")
> + set(fname "${CMAKE_MATCH_1}")
> + if(NOT "${fname}" MATCHES
> "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
> + message(FATAL_ERROR "Could not extract tarball filename from
> url:\n ${url}")
> + endif()
Please try to structure the logic right in the if/elseif part.
Matching in those also sets `CMAKE_MATCH_*` variables so one
does not need to double-match.
Also, the `([^/]*)\\?.*` part of the regex should be more
like `([^/?]*)\\?.*` to avoid eagerly matching early `?`.
Thanks,
-Brad
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers