소스 검색

libarchive: Fix major() check for LSB 4.0 (#11648)

The LSB header files define major() as a macro but if it is ever called
the macro references symbols not available at link time.  Improve the
test for major() to actually call the macro and try to link.  This
approach is based on upstream libarchive SVN commit 2866 which fixed
libarchive issue 125, submitted in response to CMake issue #11648.

Inspired-by: Tim Kientzle <[email protected]>
Brad King 15 년 전
부모
커밋
cf5ad18340
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      Utilities/cmlibarchive/CMakeLists.txt

+ 6 - 2
Utilities/cmlibarchive/CMakeLists.txt

@@ -415,8 +415,12 @@ CHECK_SYMBOL_EXISTS(strerror_r       "string.h"   HAVE_STRERROR_R)
 CHECK_SYMBOL_EXISTS(strftime         "time.h"     HAVE_STRFTIME)
 CHECK_SYMBOL_EXISTS(vprintf          "stdio.h"    HAVE_VPRINTF)
 
-CHECK_SYMBOL_EXISTS(major            "sys/mkdev.h"     MAJOR_IN_MKDEV)
-CHECK_SYMBOL_EXISTS(major            "sys/sysmacros.h" MAJOR_IN_SYSMACROS)
+CHECK_C_SOURCE_COMPILES(
+  "#include <sys/mkdev.h>\nint main() { return major(256); }"
+  MAJOR_IN_MKDEV)
+CHECK_C_SOURCE_COMPILES(
+  "#include <sys/sysmacros.h>\nint main() { return major(256); }"
+  MAJOR_IN_SYSMACROS)
 
 IF(HAVE_STRERROR_R)
   SET(HAVE_DECL_STRERROR_R 1)