From 04f4624718a55cf734e7911de614b44ecb6db35f Mon Sep 17 00:00:00 2001 From: Evan Miller Date: Mon, 20 Sep 2021 08:42:40 -0400 Subject: [PATCH] Explicitly test for libproc.h (#1916) This change adds support for ancient macOS lacking libproc. It also eliminates a bug where exiv2 could not be built on case-sensitive file systems (the header file is properly TargetConditionals.h). --- cmake/config.h.cmake | 3 +++ cmake/generateConfigFile.cmake | 1 + src/futils.cpp | 5 ++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 19f7cff3..740c2d0e 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -41,6 +41,9 @@ // Define if you have the munmap function. #cmakedefine EXV_HAVE_MUNMAP +/* Define if you have the header file. */ +#cmakedefine EXV_HAVE_LIBPROC_H + /* Define if you have the header file. */ #cmakedefine EXV_HAVE_UNISTD_H diff --git a/cmake/generateConfigFile.cmake b/cmake/generateConfigFile.cmake index 5298ecf0..05e16341 100644 --- a/cmake/generateConfigFile.cmake +++ b/cmake/generateConfigFile.cmake @@ -36,6 +36,7 @@ int main() { return 0; }" EXV_STRERROR_R_CHAR_P ) +check_include_file_cxx( "libproc.h" EXV_HAVE_LIBPROC_H ) check_include_file_cxx( "unistd.h" EXV_HAVE_UNISTD_H ) check_include_file_cxx( "sys/mman.h" EXV_HAVE_SYS_MMAN_H ) diff --git a/src/futils.cpp b/src/futils.cpp index a3a61d54..1f81e3fc 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -48,8 +48,7 @@ #if defined(_MSC_VER) #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #elif defined(__APPLE__) -#include -#ifndef TARGET_OS_IPHONE +#if defined(EXV_HAVE_LIBPROC_H) #include #endif #endif @@ -458,7 +457,7 @@ namespace Exiv2 { CloseHandle(processHandle); } #elif defined(__APPLE__) - #ifndef TARGET_OS_IPHONE + #ifdef EXV_HAVE_LIBPROC_H const int pid = getpid(); char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; if (proc_pidpath (pid, pathbuf, sizeof(pathbuf)) > 0) {