View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008035CMakeCMakepublic2008-11-06 06:522009-01-07 14:57
ReporterJed K Brown 
Assigned ToBrad King 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0008035: Make find_library() check PATHS before system directories
DescriptionI have

/usr/lib/libparmetis.a (built using Open MPI 1.2.8)
/opt/mpich2/lib/libparmetis.a (built using MPICH2 1.1.0a1)

While these define and reference all the same symbols, they are *not* ABI-compatible. For instance sizeof(MPI_Comm) is different. If the wrong version is linked, we will not get any warnings by the build system, but the executable will seg-fault.

# resolves (incorrectly) to /usr/lib/libparmetis.a
find_library (PARMETIS_LIB parmetis PATHS /opt/mpich2/lib)

# resolves to /opt/mpich2/lib/libparmetis.a
find_library (PARMETIS_LIB parmetis HINTS /opt/mpich2/lib)

Many modules use PATHS for what HINTS is intended for, and will resolve all subcomponents to the wrong library when trying to find a version in a non-standard location. The documentation says PATHS should be searched before system directories.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0014478)
Brad King (manager)
2009-01-07 14:57

Where do the docs say PATHS come before system dirs? It is this:

       3. Search the paths specified by the HINTS option. These should be
       paths computed by system introspection, such as a hint provided by the
       location of another item already found. Hard-coded guesses should be
       specified with the PATHS option.

...

       5. Search cmake variables defined in the Platform files for the
       current system. This can be skipped if NO_CMAKE_SYSTEM_PATH is
       passed.

          <prefix>/lib for each <prefix> in CMAKE_SYSTEM_PREFIX_PATH
          CMAKE_SYSTEM_LIBRARY_PATH
          CMAKE_SYSTEM_FRAMEWORK_PATH

       6. Search the paths specified by the PATHS option or in the
       short-hand version of the command. These are typically hard-coded
       guesses.

This means that HINTS come before system dirs and PATHS come after them. The HINTS documentation explicitly states that hard-coded guesses should be PATHS. This is absolutely necessary so that users and system configurations can override hard-coded guesses by setting up their environments correctly. HINTS should only be paths computed from something on the system and never be hard-coded paths.

This is not a bug in find_library. If there is any bug it is either in the find-module containing the line you mention or in the system's configuration (for example linking with -lparmetis will get the wrong one too). If /opt/mpich2 appears in either CMAKE_SYSTEM_PREFIX_PATH or CMAKE_PREFIX_PATH the proper library will be found.

 Issue History
Date Modified Username Field Change
2008-11-06 06:52 Jed K Brown New Issue
2009-01-07 14:36 Bill Hoffman Status new => assigned
2009-01-07 14:36 Bill Hoffman Assigned To => Brad King
2009-01-07 14:57 Brad King Note Added: 0014478
2009-01-07 14:57 Brad King Status assigned => closed
2009-01-07 14:57 Brad King Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team