KDE/kdebase/runtime/cmake/modules

David Faure faure at kde.org
Tue Aug 18 13:08:21 CEST 2009


SVN commit 1012904 by dfaure:

Fix errors with libssh-0.2 (which is too old)
It defines LIBSSH_VERSION but not LIBSSH_VERSION_MAJOR, so the regex stuff fails and aborts.
Also fix logic error: libssh was used even if too old, because find_package_handle_standard_args
overwrites LIBSSH_FOUND.
CCMAIL: kde-buildsystem at kde.org


 M  +23 -12    FindLibSSH.cmake  


--- trunk/KDE/kdebase/runtime/cmake/modules/FindLibSSH.cmake #1012903:1012904
@@ -56,23 +56,34 @@
     if (LibSSH_FIND_VERSION)
       file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_MAJOR
         REGEX "#define[ ]+LIBSSH_VERSION_MAJOR[ ]+[0-9]+")
-      string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MAJOR ${LIBSSH_VERSION_MAJOR})
-      file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_MINOR
-        REGEX "#define[ ]+LIBSSH_VERSION_MINOR[ ]+[0-9]+")
-      string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MINOR ${LIBSSH_VERSION_MINOR})
-      file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_PATCH
-        REGEX "#define[ ]+LIBSSH_VERSION_MICRO[ ]+[0-9]+")
-      string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_PATCH ${LIBSSH_VERSION_PATCH})
+      # Older versions of libssh like libssh-0.2 have LIBSSH_VERSION but not LIBSSH_VERSION_MAJOR
+      if (LIBSSH_VERSION_MAJOR)
+        string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MAJOR ${LIBSSH_VERSION_MAJOR})
+	file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_MINOR
+          REGEX "#define[ ]+LIBSSH_VERSION_MINOR[ ]+[0-9]+")
+	string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MINOR ${LIBSSH_VERSION_MINOR})
+	file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_PATCH
+          REGEX "#define[ ]+LIBSSH_VERSION_MICRO[ ]+[0-9]+")
+	string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_PATCH ${LIBSSH_VERSION_PATCH})
 
-      set(LibSSH_VERSION ${LIBSSH_VERSION_MAJOR}.${LIBSSH_VERSION_MINOR}.${LIBSSH_VERSION_PATCH})
+	set(LibSSH_VERSION ${LIBSSH_VERSION_MAJOR}.${LIBSSH_VERSION_MINOR}.${LIBSSH_VERSION_PATCH})
 
-      include(FindPackageVersionCheck)
-      find_package_version_check(LibSSH DEFAULT_MSG)
+	include(FindPackageVersionCheck)
+	find_package_version_check(LibSSH DEFAULT_MSG)
+      else (LIBSSH_VERSION_MAJOR)
+        message(STATUS "LIBSSH_VERSION_MAJOR not found in ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h, assuming libssh is too old")
+        set(LIBSSH_FOUND FALSE)
+      endif (LIBSSH_VERSION_MAJOR)
     endif (LibSSH_FIND_VERSION)
   endif (SSH_FOUND)
 
-  include(FindPackageHandleStandardArgs)
-  find_package_handle_standard_args(LibSSH DEFAULT_MSG LIBSSH_LIBRARIES LIBSSH_INCLUDE_DIRS)
+  # If the version is too old, but libs and includes are set,
+  # find_package_handle_standard_args will set LIBSSH_FOUND to TRUE again,
+  # so we need this if() here.
+  if (LIBSSH_FOUND)
+    include(FindPackageHandleStandardArgs)
+    find_package_handle_standard_args(LibSSH DEFAULT_MSG LIBSSH_LIBRARIES LIBSSH_INCLUDE_DIRS)
+  endif (LIBSSH_FOUND)
 
   # show the LIBSSH_INCLUDE_DIRS and LIBSSH_LIBRARIES variables only in the advanced view
   mark_as_advanced(LIBSSH_INCLUDE_DIRS LIBSSH_LIBRARIES)


More information about the Kde-buildsystem mailing list