Branch: master

69a43103 2015-09-18 04:05:58 Timothy Pearson
Attempt to fix cryptsetup version detection yet again
The library authors would have done well to include a version number #define in the header...
M CMakeLists.txt
M config.h.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a5ff0f7..f16fce0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -697,11 +697,22 @@
   endif( NOT LIBCRYPTSETUP_FOUND )
   set( HAVE_CRYPTSETUP 1 )
   if ( HAVE_CRYPTSETUP )
+    # save CMAKE_REQUIRED_LIBRARIES
+    set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
+    set( CMAKE_REQUIRED_LIBRARIES ${LIBCRYPTSETUP_LIBRARIES} )
     check_c_source_compiles("
       #include <stddef.h>
       #include <libcryptsetup.h>
-      int main(int argc, char *argv[]) { crypt_keyslot_info status = CRYPT_SLOT_INVALID; crypt_get_type(NULL); return 0; } "
+      int main(int argc, char *argv[]) { crypt_keyslot_info status = CRYPT_SLOT_INVALID; return 0; } "
       HAVE_NEW_CRYPTSETUP )
+    check_c_source_compiles("
+      #include <stddef.h>
+      #include <libcryptsetup.h>
+      int main(int argc, char *argv[]) { crypt_get_type(NULL); return 0; } "
+      HAVE_CRYPTSETUP_GET_TYPE )
+    # restore CMAKE_REQUIRED_LIBRARIES
+    set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} )
+    unset( bak_CMAKE_REQUIRED_LIBRARIES )
   endif( )
   if ( NOT HAVE_NEW_CRYPTSETUP )
     set( CRYPTSETUP_OLD_API 1 )
diff --git a/config.h.cmake b/config.h.cmake
index 0eb6f67..8c104d5 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -151,6 +151,9 @@
 /* Defines if your system uses the old cryptsetup API */
 #cmakedefine CRYPTSETUP_OLD_API 1
 
+/* Defines if your system uses a cryptsetup API that includes crypt_get_type */
+#cmakedefine HAVE_CRYPTSETUP_GET_TYPE 1
+
 /* Define to 1 if you have the <ctype.h> header file. */
 #cmakedefine HAVE_CTYPE_H 1