Browse Source

Use CMake's regex instead of 'grep' because it is not universal.
The 'grep' command on macOS is from BSD which requires different option than Linux one to enable extended or Perl-compatible regex parsing.
[skip appveyor] [ci only: OSX]

Yao Wei Tjong 姚伟忠 9 years ago
parent
commit
201cfc991c
1 changed files with 3 additions and 2 deletions
  1. 3 2
      CMake/Modules/CheckHost.cmake

+ 3 - 2
CMake/Modules/CheckHost.cmake

@@ -31,7 +31,7 @@
 #  HAS_LIB64 (multilib capable)
 #  HAS_LIB64 (multilib capable)
 #  CCACHE_VERSION (when using Clang with ccache enabled)
 #  CCACHE_VERSION (when using Clang with ccache enabled)
 #
 #
-# Neither here or there:
+# Neither here nor there:
 #  BASH_ON_WINDOWS
 #  BASH_ON_WINDOWS
 #
 #
 
 
@@ -75,7 +75,8 @@ else ()
     # Test if PCH could be enabled in tandem with ccache when using Clang compiler toolchain
     # Test if PCH could be enabled in tandem with ccache when using Clang compiler toolchain
     if ("$ENV{USE_CCACHE}" AND CMAKE_CXX_COMPILER_ID MATCHES Clang)
     if ("$ENV{USE_CCACHE}" AND CMAKE_CXX_COMPILER_ID MATCHES Clang)
         if (NOT DEFINED CCACHE_VERSION)
         if (NOT DEFINED CCACHE_VERSION)
-            execute_process (COMMAND ccache --version COMMAND head -1 COMMAND grep -oP "(?:\\d+\\.)?(?:\\d+\\.)?\\d+" RESULT_VARIABLE CCACHE_EXIT_CODE OUTPUT_VARIABLE CCACHE_VERSION ERROR_QUIET)
+            execute_process (COMMAND ccache --version COMMAND head -1 RESULT_VARIABLE CCACHE_EXIT_CODE OUTPUT_VARIABLE CCACHE_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+            string (REGEX MATCH "[^ .]+\\.[^.]+\\.[^ ]+" CCACHE_VERSION "${CCACHE_VERSION}")    # Stringify as it could be empty when an error has occured
             if (CCACHE_EXIT_CODE EQUAL 0)
             if (CCACHE_EXIT_CODE EQUAL 0)
                set (CCACHE_VERSION ${CCACHE_VERSION} CACHE INTERNAL "ccache version")
                set (CCACHE_VERSION ${CCACHE_VERSION} CACHE INTERNAL "ccache version")
            endif ()
            endif ()