diff --git a/CMakeLists.txt b/CMakeLists.txt index 35b48770..d0285be0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,17 +43,13 @@ if (POLICY CMP0054) endif(POLICY CMP0054) # Read version information from configure.ac. -FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure) -STRING(REGEX REPLACE ";" "\\\\;" configure "${configure}") -STRING(REGEX REPLACE "\n" ";" configure "${configure}") +FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure REGEX "^LIBTIFF_.*=") foreach(line ${configure}) foreach(var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION LIBTIFF_CURRENT LIBTIFF_REVISION LIBTIFF_AGE) - if(NOT ${var}) - string(REGEX MATCH "^${var}=(.*)" ${var}_MATCH "${line}") - if(${var}_MATCH) - string(REGEX REPLACE "^${var}=(.*)" "\\1" ${var} "${line}") - endif() + if(NOT ${var} AND line MATCHES "^${var}=(.*)") + set(${var} "${CMAKE_MATCH_1}") + break() endif() endforeach() endforeach()