]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: use CHECK_STRUCT_HAS_MEMBER for checking member variables in struct
authorKefu Chai <kchai@redhat.com>
Wed, 13 Jul 2016 09:13:12 +0000 (17:13 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 13 Jul 2016 09:13:20 +0000 (17:13 +0800)
we were using CHECK_CXX_SOURCE_COMPILES() for this purpose, which was a
little bit clumsy.

Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt

index f9598c40c8587e944c650d97f0a89b12119d4af5..4b3bacc44c5dd676045da7f45201486e1e9472af 100644 (file)
@@ -135,18 +135,12 @@ CHECK_CXX_SOURCE_COMPILES("
   #include <string.h>
   int main() { char x = *strerror_r(0, &x, sizeof(x)); return 0; }
   " STRERROR_R_CHAR_P)
-CHECK_CXX_SOURCE_COMPILES("
-  #include <sys/stat.h>
-  #include <stdio.h>
-  int main() { struct stat foo = {}; foo.st_mtim.tv_nsec = 0;
-  return 0; } 
-  " HAVE_STAT_ST_MTIM_TV_NSEC)
-CHECK_CXX_SOURCE_COMPILES("
-  #include <sys/stat.h>
-  #include <stdio.h>
-  int main() { struct stat foo = {}; foo.st_mtimespec.tv_nsec = 0;
-  return 0; } 
-  " HAVE_STAT_ST_MTIMESPEC_TV_NSEC)
+
+include(CheckStructHasMember)
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
+  HAVE_STAT_ST_MTIM_TV_NSEC LANGUAGE C)
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
+  HAVE_STAT_ST_MTIMESPEC_TV_NSEC LANGUAGE C)
 CHECK_CXX_SOURCE_COMPILES("
   int main() { float f = 12.3; int n = static_cast<int>(f); return 0; }
   " HAVE_STATIC_CAST)