[cmake-developers] [CMake 0013271]: is_file_executable() from GetPrerequisites.cmake erroneously returns 0 for universal binaries (MacOSX)

Mantis Bug Tracker mantis at public.kitware.com
Tue Jun 5 12:01:29 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=13271 
====================================================================== 
Reported By:                recryn
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13271
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-06-05 18:01 CEST
Last Modified:              2012-06-05 18:01 CEST
====================================================================== 
Summary:                    is_file_executable() from GetPrerequisites.cmake
erroneously returns 0 for universal binaries (MacOSX)
Description: 
On UNIX is_file_executable() executes the tool 'file' and then compares the
returned string with "executable": if("${file_ov}" MATCHES "executable")

However, on MacOSX, there are several 'file' tools available (macports, fink)
which do not share the same output format. Most notably, the output string does
not always match "executable" if the file is a universal binary. Here are some
possible output strings of 'file' for three different executables on a Mac:
  Mach-O executable i386
  Mach-O 64-bit executable
  Mach-O fat file with 2 architectures

'file /bin/ls' results just in:
/bin/ls: Mach-O fat file with 2 architectures

Note, that a library would be reported as: "Mach-O 64-bit dynamically linked
shared library". So matching Mach-O is no good either.

Ideally is_file_executable() would call 'otool -hv' on APPLE and match the
result with "EXECUTE", e.g.:

otool -hv /bin/ls
/bin/ls:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL LIB64     EXECUTE    13       1928   NOUNDEFS
DYLDLINK TWOLEVEL

Steps to Reproduce: 
1. Install 'file' from macports:
port install file

2. Prepend macports binary dir (/opt/local/bin) to PATH

3. With a project that uses fixup_bundle:
cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;i386"
make
cpack -G Bundle --verbose

[...]
CPack Verbose:   libs=''
CPack Verbose:   dirs=''
CPack Verbose: warning: *NOT* handled - not .app dir, not executable file...
CMake Error at /opt/local/share/cmake-2.8/Modules/MyBundleUtilities.cmake:723
(message):
  error: fixup_bundle: not a valid bundle
Call Stack (most recent call first):
  /tmp/trunk/build/cmake/dist/cmake_install.cmake:38 (fixup_bundle)
  /tmp/trunk/build/cmake_install.cmake:36 (INCLUDE)

Additional Information: 
Patch attached.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-06-05 18:01 recryn         New Issue                                    
2012-06-05 18:01 recryn         File Added: GetPrerequisites.cmake.diff         
          
======================================================================




More information about the cmake-developers mailing list