cmake-conan icon indicating copy to clipboard operation
cmake-conan copied to clipboard

conan_check fails with "Invalid escape sequence" error when optional VERSION argument is supplied

Open xmkg opened this issue 5 years ago • 1 comments

Following command fails with CMake version 3.16.3, Conan version 1.25.2.

conan_check(VERSION 1.25.0 REQUIRED)

The produced log output is as follows:

[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/workspace/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "/workspace/build/CMakeFiles/CMakeError.log".
[cmake] CMake Error at .hadouken/cmake/modules/helper/Conan.cmake:542 (string):
[cmake]   Syntax error in cmake code at
[cmake] 
[cmake]     /workspace/.hadouken/cmake/modules/helper/Conan.cmake:542
[cmake] 
[cmake]   when parsing string
[cmake] 
[cmake]     .*Conan version ([0-9]+\.[0-9]+\.[0-9]+)
[cmake] 
[cmake]   Invalid escape sequence \.
[cmake] Call Stack (most recent call first):
[cmake]   dependencies.cmake:14 (conan_check)
[cmake]   CMakeLists.txt:40 (include)

It is caused by unescaped backslash found in CONAN_VERSION if block.

 if(DEFINED CONAN_VERSION)
        string(REGEX MATCH ".*Conan version ([0-9]+\.[0-9]+\.[0-9]+)" FOO
            "${CONAN_VERSION_OUTPUT}")
        if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION})
            message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \
                required: ${CONAN_VERSION}. Consider updating via 'pip \
                install conan==${CONAN_VERSION}'.")
        endif()
    endif()

I'll be issuing a pull request fixing this issue.

xmkg avatar Jun 03 '20 10:06 xmkg

Hi @mustafakemalgilor, Thanks a lot for reporting and the PR, we will add the fix for the next release.

czoido avatar Jun 08 '20 08:06 czoido