[CMake] FIND_LIBRARY and PATH_SUFFIXES: documentation or implementation bug

Marcel Loose loose at astron.nl
Fri Mar 25 08:17:00 EDT 2011


Hi Michael,

> AFAICS, this is not true, see cmFindBase::AddPathSuffixes(). The paths
> with the additional suffixes are searched first, but the paths without
> the suffixes are considered, too. Look at the following
CMakeLists.txt:
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
> PROJECT(PATHSUFFIXES NONE)
> FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib/config)
> FILE(WRITE ${CMAKE_BINARY_DIR}/lib/libxyz.so "")
> FILE(WRITE ${CMAKE_BINARY_DIR}/lib/config/libxyz.a "")
> SET(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
> FIND_LIBRARY(XYZ1 xyz PATH_SUFFIXES config)
> MESSAGE("XYZ1: ${XYZ1}")
> SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
> FIND_LIBRARY(XYZ2 xyz PATH_SUFFIXES config)
> MESSAGE("XYZ2: ${XYZ2}")
>
> This yields:
>
> XYZ1: ${CMAKE_BINARY_DIR}/lib/config/libxyz.a
> XYZ2: ${CMAKE_BINARY_DIR}/lib/libxyz.so

You are right. I can reproduce this output. I now understand what led me
to the wrong conclusion.

I'm still using cmake 2.6.4 and there's a crucial difference between the
FindPythonLibs.cmake that ships with cmake 2.6.4 and 2.8.4. The latter
does indeed first search the "normal" path and only then uses the
"config" path suffix. The former, however, immediately starts of using
the "config" path suffix. 

Problem solved.

Regards,
Marcel Loose.




More information about the CMake mailing list